We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Properties on object passed to Save and Insert actions are NULL

I for the life of me can't figure out the problem.

I've got 3 grid controls, all are having the same behavior.
The object that is passed to the Insert or Save action appears to be an instance of an object, but all of the properties are null.  Its impossible to put information into the repository if it all comes across as NULL....

Here is the Grid definition:
                    .EnablePaging()    /*Paging Enabled*/
                                /*.Grouping( group => group.GroupDescriptors(grouped => grouped.Add(c=>c.VIN)).IsExpanded(true))    Grouping Enabled for VIN */
                    .Column(cols =>
                        cols.Add(c => c.VIN).HeaderText("VIN").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(130);
                        cols.Add(c => c.Type).HeaderText("Type").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(200).CellEditType(CellEditType.DropdownEdit);
                        cols.Add(c => c.Make).HeaderText("Make").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(130);
                        cols.Add(c => c.Model).HeaderText("Model").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(130);
                        cols.Add(c => c.Year).HeaderText("Year").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(100);
                        cols.Add(c => c.Color).HeaderText("Color").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(100);
                        cols.Add(c => c.LicensePlate).HeaderText("Plate").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(100);
                        cols.Add(c => c.Odometer).HeaderText("Odometer").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(100).CellEditType(CellEditType.NumericEdit);
                    .ClientSideEvents(events => { events.OnCellEdit("SetDropDownData"); })
                    .Mappers(mapper => { mapper.InsertAction("AddVehicle").SaveAction("SaveVehicle").DeleteAction("DeleteVehicle").Action("Vehicle"); })
                    .Editing(edit => { edit.AllowEdit(true).AllowNew(true).AllowDelete(true); edit.EditMode(GridEditMode.AutoExcel); edit.AddNewRowPosition(RowPosition.Bottom); edit.PrimaryKey(key => key.Add(p => p.VIN)); })
                    .ToolBar(tools => { tools.Add(GridToolBarItems.AddNew).Add(GridToolBarItems.Edit).Add(GridToolBarItems.Delete).Add(GridToolBarItems.Update).Add(GridToolBarItems.Cancel); })

and here is the code from the controller:
 #region Vehicle Grid

        public ActionResult Vehicle(PagingParams args)
            IEnumerable data = Models.VehicleRepository.GetAllRecords();
            return data.GridJSONActions<Vehicle>();


        public ActionResult AddVehicle(Vehicle veh)
            var data = Models.VehicleRepository.GetAllRecords();
            return data.GridJSONActions<Vehicle>();

        public ActionResult SaveVehicle(Vehicle veh)
            var data = Models.VehicleRepository.GetAllRecords();
            return data.GridJSONActions<Vehicle>();

        public ActionResult DeleteVehicle(string VIN)
            if (ModelState.IsValid)
            var data = Models.VehicleRepository.GetAllRecords();
            return data.GridJSONActions<Vehicle>();

        #endregion Vehicle Grid

Vehicle is defined as:
public class Vehicle
        [Display(Name = "Year")]
        public int Year { get; set; }
        [Display(Name = "Make")]
        public string Make { get; set; }
        [Display(Name = "Model")]
        public string Model { get; set; }
        [Display(Name = "VIN")]
        public string VIN { get; set; }
        [Display(Name = "License Plate")]
        public string LicensePlate { get; set; }
        [Display(Name = "Color")]
        public string Color { get; set; }
        [Display(Name = "Odometer")]
        public int Odometer { get; set; }
        [Display(Name = "Membership Type")]
        public string Type { get; set; }

When SaveVehicle or AddVehicle is called, the veh object is valid, but all of the data (Year, Make, Model, VIN, etc) are all NULL.

Any ideas?
I've wasted hours on trying to figure out this nonsense.

1 Reply

HJ Hariharan J V Syncfusion Team September 25, 2013 09:07 AM UTC

Hi Dan Guisinger,

Thanks for using Syncfusion products.

We suggest you to use BulkSave method for add, delete and update the records in the excel edit mode. Please refer the below code snippets.

        public ActionResult BulkSave([Bind(Prefix = "updatedRecords")]IEnumerable<EditableOrder> orders, [Bind(Prefix = "addedRecords")]IEnumerable<EditableOrder> addRcrds, [Bind(Prefix = "deletedRecords")]IEnumerable<EditableOrder> delRcrds)
            if (orders != null)
            if (addRcrds != null)
            if (delRcrds != null)
            var data = OrderRepository.GetAllRecords();
            return data.GridJSONActions<EditableOrder>();

For your convenience, we have prepared a simple sample to demonstrate this and the same can be downloaded from the below link.

Sample: www.syncfusion.com/downloads/support/directtrac/general/Exceledit1404297500.zip

Please let us know if you need any further assistance.

Hariharan J.V.

Live Chat Icon For mobile
Up arrow icon