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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

IEnumerable in ViewModel

Thread ID:

Created:

Updated:

Platform:

Replies:

132649 Sep 13,2017 10:14 PM UTC Sep 14,2017 03:52 PM UTC ASP.NET MVC 1
loading
Tags: Grid
Bernard Jurlina
Asked On September 13, 2017 10:14 PM UTC

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

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;