Can not add new Record in Grid

Re: Can not add new Record in Grid via Dialog or Inline.
Am porting an existing ASP .Net Core Spplication
When I click the Button to Save nothing happens.
The Grid is Scaffolded from Syncfusion tool and works as designed except for the ability to add new Record
Model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace MyToolsSync03.Models
{
public class AcctCusts

{
private DateTime _created;

public AcctCusts()

{ }

[Key]
public int AcctCustId { get; set; }
public string AcctName { get; set; }
public string BusinessSec { get; set; }
public string Regulatory { get; set; }

// ******** Start Section - Date and Time Calculations - Created Da private DateTime _created = DateTime.MinValue;

[Display(Name = "Created On")]
[DataType(DataType.DateTime)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime Created
{
get
{
return (_created == DateTime.MinValue) ? DateTime.Now : _created;
}
set { _created = value; }
}
// ********Date and Time Calculations - Created



// public DateTime ValidToDate { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
public string Contact1Name { get; set; }
public string Contact1Phone { get; set; }
public string Contact1Email { get; set; }
public string Contact2Name { get; set; }
public string Contact2Phone { get; set; }
public string Contact2Email { get; set; }
public string WbSiteURL { get; set; }
public string CreatedBy { get; set; }
// public string CreteDate { get; set; }
public string ModifyDate { get; set; }



}
}

Controller
using Syncfusion.EJ2.Base;
using System.Collections;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using MyToolsSync03.Models;
using MyToolsSync03.Data;
namespace MyToolsSync03.Controllers
{
public class AcctCustsController : Controller
{
private MyToolsSync03DBContext _context;

public AcctCustsController(MyToolsSync03DBContext Context)
{
this._context=Context;
}
public ActionResult Index()
{
return View();
}
public ActionResult UrlDatasource([FromBody]DataManagerRequest dm)
{

IEnumerable DataSource = _context.AcctCusts.ToList();

DataOperations operation = new DataOperations();
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
DataSource = operation.PerformSorting(DataSource, dm.Sorted);
}
if (dm.Search != null && dm.Search.Count > 0)
{
DataSource = operation.PerformSearching(DataSource, dm.Search); //Search
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
}
int count = DataSource.Cast().Count();
if (dm.Skip != 0)//Paging
{
DataSource = operation.PerformSkip(DataSource, dm.Skip);
}
if (dm.Take != 0)
{
DataSource = operation.PerformTake(DataSource, dm.Take);
}
return Json(new { result = DataSource, count = count });
}
public ActionResult Insert([FromBody]CRUDModel value)
{
//do stuff
_context.AcctCusts.Add(value.Value);
_context.SaveChanges();
return Json(value);

}
public ActionResult Update([FromBody]CRUDModel value)
{
//do stuff
var ord = value;

AcctCusts val = _context.AcctCusts.Where(or => or.AcctCustId == ord.Value.AcctCustId).FirstOrDefault();
val.AcctCustId=ord.Value.AcctCustId;
val.AcctName=ord.Value.AcctName;
val.BusinessSec=ord.Value.BusinessSec;
val.Regulatory=ord.Value.Regulatory;
val.Created=ord.Value.Created;
val.Address1=ord.Value.Address1;
val.Address2=ord.Value.Address2;
val.City=ord.Value.City;
val.State=ord.Value.State;
val.Country=ord.Value.Country;
val.Contact1Name=ord.Value.Contact1Name;
val.Contact1Phone=ord.Value.Contact1Phone;
val.Contact1Email=ord.Value.Contact1Email;
val.Contact2Name=ord.Value.Contact2Name;
val.Contact2Phone=ord.Value.Contact2Phone;
val.Contact2Email=ord.Value.Contact2Email;
val.WbSiteURL=ord.Value.WbSiteURL;
val.CreatedBy=ord.Value.CreatedBy;
val.ModifyDate=ord.Value.ModifyDate;
_context.SaveChanges();
return Json(value);
}
public ActionResult Delete([FromBody]CRUDModel value)
{
//do stuff
AcctCusts order = _context.AcctCusts.Where(c => c.AcctCustId == (int)value.Key).FirstOrDefault();
_context.AcctCusts.Remove(order);
_context.SaveChanges();
return Json(order);
}
}
}
View


7 Replies

L. L. August 19, 2020 01:08 AM UTC

View
 <!-- Default box -->
        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title text-primary"><i class="fa fa-building-o"></i> ACCOUNTS</h3>
                <div class="box-tools pull-right">
                    <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
                            title="Collapse">
                        <i class="fa fa-minus"></i>
                    </button>
                    <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
                        <i class="fa fa-times"></i>
                    </button>
                </div>
            </div>
            <div class="box-body">
                @*<div id="Grid"></div>*@
                <ejs-grid id="Grid" height="272" 
                          allowPaging="true"
                          allowSorting="true"
                          allowResizing="true"
                          allowReordering="true"
                          allowGrouping="true"
                          toolbar="@(new List<string>() { "Search", "Add", "Edit", "Delete","Update","Cancel" , "ExcelExport" , "CsvExport" ,"PdfExport"})"
                          allowFiltering="true"
                          allowSelection="true"
                          allowExcelExport="true"
                          allowPdfExport="true"
                          toolbarClick="toolbarClick">
                    <e-data-manager url="/AcctCusts/UrlDataSource" adaptor="UrlAdaptor" insertUrl="/AcctCusts/Insert" updateUrl="/AcctCusts/Update" removeUrl="/AcctCusts/Delete"></e-data-manager>
                    @*<e-data-manager url="/api/AcctCusts" insertUrl="/api/AcctCusts/Insert" updateUrl="/api/AcctCusts/Update" removeUrl="/api/AcctCusts/Remove" adaptor="WebApiAdaptor" crossdomain="true"></e-data-manager>*@

                    <e-grid-filterSettings type="Menu"></e-grid-filterSettings>
                    <e-grid-editSettings
                                         allowAdding="true"
                                         allowDeleting="true"
                                         allowEditing="true"
                                         mode="Dialog">
                    </e-grid-editSettings>

                    <e-grid-selectionsettings type="Single"></e-grid-selectionsettings>

                    <e-grid-columns>
                        <e-grid-column type="checkbox" width="50"></e-grid-column>
                        <e-grid-column field="AcctCustId" headerText="AcctCustId" isPrimaryKey="true" isIdentity="true"></e-grid-column>
                        <e-grid-column field="AcctName" headerText="AcctName"></e-grid-column>
                        <e-grid-column field="BusinessSec" headerText="BusinessSec"></e-grid-column>
                        <e-grid-column field="Regulatory" headerText="Regulatory"></e-grid-column>
                        @*<e-grid-column field="Created" headerText="Created"></e-grid-column>*@
                        <e-grid-column field="Created" headerText="Created" editType="datepickeredit" textAlign="Right" format="yMd" minWidth="8" width="200"></e-grid-column>
                        <e-grid-column field="Address1" headerText="Address1"></e-grid-column>
                        <e-grid-column field="Address2" headerText="Address2"></e-grid-column>
                        <e-grid-column field="City" headerText="City"></e-grid-column>
                        <e-grid-column field="State" headerText="State"></e-grid-column>
                        <e-grid-column field="Country" headerText="Country"></e-grid-column>
                        <e-grid-column field="Contact1Name" headerText="Contact1Name"></e-grid-column>
                        <e-grid-column field="Contact1Phone" headerText="Contact1Phone"></e-grid-column>
                        <e-grid-column field="Contact1Email" headerText="Contact1Email"></e-grid-column>
                        <e-grid-column field="Contact2Name" headerText="Contact2Name"></e-grid-column>
                        <e-grid-column field="Contact2Phone" headerText="Contact2Phone"></e-grid-column>
                        <e-grid-column field="Contact2Email" headerText="Contact2Email"></e-grid-column>
                        <e-grid-column field="WbSiteURL" headerText="WbSiteURL"></e-grid-column>
                        <e-grid-column field="CreatedBy" headerText="CreatedBy"></e-grid-column>
                        @*<e-grid-column field="ModifyDate" headerText="ModifyDate"></e-grid-column>*@
                        <e-grid-column field="ModifyDate" headerText="ModifyDate" editType="datepickeredit" textAlign="Right" format="yMd" minWidth="8" width="200"></e-grid-column>
                    </e-grid-columns>
                </ejs-grid>
            </div>
            <!-- /.box-body -->
            <div class="box-footer">

            </div>
            <!-- /.box-footer-->
        </div>
        <!-- /.box -->

@*<ejs-scripts></ejs-scripts>*@


@section Scripts{


    <script>
        function toolbarClick(args) {
            if (args.item.id === this.element.id + '_pdfexport') {
                this.pdfExport();
            }
            if (args.item.id === this.element.id + '_csvexport') {
                this.csvExport();
            }
            if (args.item.id === this.element.id + '_excelexport') {
                this.excelExport();
            }
        }
    </script>


}


BS Balaji Sekar Syncfusion Team August 19, 2020 09:51 AM UTC

Hi Customer, 
 
Greetings from the Syncfusion support. 
 
Before proceeding with your query, we need additional information about the mentioned query, so please share with us the details below that will help validate further. 
 
  • Share the screenshot of Network tab while perform the insert action.
  • Bind actionFailure event if its triggered then share the arguments details.
  • Share the video demonstration of the problem.
  • Ensure the Syncfusion Essential Studio version.
 
Regards, 
Balaji Sekar 



L. L. August 19, 2020 02:23 PM UTC

I am attaching a Video as requested

There are no Errors being thrown.


Attachment: Syncfusion157201_215058d9.7z


BS Balaji Sekar Syncfusion Team August 20, 2020 12:46 PM UTC

Hi Customer,  
 
Thanks for your update. 
 
We have watched your video as well as we suspect that insert method (AcctCusts.cs) has comments on you. Please ensure that such a method is invoked or not, when the insert action of the Grid is being performed. 
 
In our previous update, we have requested the screenshot of network tab when perform the insert action and bind actionFailure event if it is triggered then share the arguments details 

Please share the above requested details regarding your query it will be helpful for us to provide a better solution as soon as possible. 
 
Regards, 
Balaji Sekar 



L. L. August 20, 2020 02:25 PM UTC

I am not sure what you mean by Network Tab but I ran in Debug Mode in Visual Studio and now am getting a SystemReferenceException Null Value Error and the only thin I can think of that is Null is the ID Field.

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.  Source=XfessToolsSync03
  StackTrace:
   at XfessToolsSync03.Controllers.AcctCustsController.Insert(CRUDModel`1 value) in C:\Users\L\source\Repos\XfessToolsSync03\Controllers\AcctCustsController.cs:line 54

Attaching Image



L. L. August 20, 2020 02:47 PM UTC

Visual Studio Image attached

Attachment: AcctCust_Null_Reference20200820_100837_44cbc035.7z


BS Balaji Sekar Syncfusion Team August 21, 2020 05:47 AM UTC

Hi Customer,  
  
We have created a new incident under your Direct trac account to follow up with this query. We suggest you to follow up with the incident for further updates. Please log in using the below link.     

  
Regards,  
Balaji Sekar 


Loader.
Up arrow icon