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

IEnumerable in ViewModel

I'm trying to work with IEnumerable in a ViewModel and display it in a grid.

Everything loads and displays fine when I open then view, I have three records in AspNetUsersFirma, and the grid shows it correctly.
But on post, model.AspNetUsersFirma is always null. I know that the part for saving that in the controller is missing, but what to save if model.AspNetUsersFirma is empty.

I'm certainly doing something wrong.
My code is in attached file.

Thanks!
Bernard.

Attachment: Sample_e57eac3d.zip

1 Reply

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team September 14, 2017 03:52 PM UTC

Hi Bernard, 

Thanks for contacting Syncfusion Support. 

We have checked your query and we need some additional information to find the cause of the issue. Could you please share us the following details given below. 

1. Please confirm whether you have faced the issue while saving records on Grid or on external Form. 

2. Do you want to perform CRUD operations on Grid. If you want to perform CRUD operations on Grid, we suggest you to use RemoteSaveAdaptor to perform CRUD operations. Please refer to the code example:- 

@(Html.EJ().Grid<object>("Grid") 
           .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).UpdateURL("CellEditUpdate").InsertURL("CellEditInsert").RemoveURL("CellEditDelete").Adaptor(AdaptorType.RemoteSaveAdaptor)) 
          .AllowPaging() 
          .Columns(col => 
              { 
                  .  .  . 
              })) 
Serverside:- 
 
public class GridController : Controller 
    { 
        public ActionResult GridFeatures() 
        { 
 
            var DataSource = new NorthwindDataContext().OrdersViews.ToList(); 
            ViewBag.datasource = DataSource; 
            return View(); 
        } 
       
        public ActionResult CellEditUpdate(EditableOrder value) 
        { 
            OrderRepository.Update(value); 
            var data = OrderRepository.GetAllRecords(); 
            return Json(value, JsonRequestBehavior.AllowGet); 
        } 
 
        public ActionResult CellEditInsert(EditableOrder value) 
        { 
            OrderRepository.Add(value); 
            var data = OrderRepository.GetAllRecords(); 
            return Json(value, JsonRequestBehavior.AllowGet); 
        } 
 
        public ActionResult CellEditDelete(int key) 
        { 
            OrderRepository.Delete(key); 
            var data = OrderRepository.GetAllRecords(); 
            return Json(data, JsonRequestBehavior.AllowGet); 
        } 
 
     } 

3. Exact scenario you are facing the issue. Screenshot/Video to demonstrate your issue. 

4. In your controller side code example, you have only given the details about AccountSettingsViewModel, please share us the code example that you have bound for Grid on serverside. 

5.If possible, provide an issue reproducing sample or hosted link.  

The provided information will help us to analyze and provide you the solution as early as possible.     
 
Regards,  

Farveen sulthana T 


Loader.
Live Chat Icon For mobile
Up arrow icon