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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid with Datatable

Thread ID:





107770 Mar 15,2013 02:17 PM UTC May 21,2014 04:25 AM UTC ASP.NET MVC (Classic) 3
Tags: Grid
Jaouen Cécile
Asked On March 15, 2013 02:17 PM UTC

Hi everybody,
I would like bind a datatable to an edit grid.
When I click on a cell to edit,  I have an error : "'Id' n'est pas un membre de type 'System.Data.DataRow'"
the column "Id" is my primary key of my table.
I tried "edit.PrimaryKey(new string[] { "Id" }); " but it doesn't work...
Please could you help me.
    .Editing(edit =>
                edit.PrimaryKey(new string[] { "Id" });    
    .ToolBar(tools =>
    .Column(cols =>
        cols.Add("French", false).AllowEditing(false);
        cols.Add("English", false).AllowEditing(false);
        public ActionResult Index()
            var data = GetDataTableLocalization();
            ViewBag.Data = data;
            return View();
        public ActionResult Index(PagingParams args)
            IEnumerable data = GetDataTableLocalization().AsEnumerable();
            return data.GridJSONActions<DataRow>();
        private DataTable GetDataTableLocalization()
            //Customer customer = new Customer();
            DataTable table = new DataTable();
            table.Columns.Add("Id", typeof(string));
            table.Columns.Add("French", typeof(string));
            table.Columns.Add("English", typeof(string));
            DataColumn[] key = new DataColumn[1];
            key[0] = table.Columns["Id"];
            table.PrimaryKey = key;
            table.Rows.Add("lienAccueil", "Accueil", "Home");
            table.Rows.Add("notifNouveauMessage", "Vous avez un nouveau message", "You have a new message");
            table.Rows.Add("txtIdentifiant", "Identifiant", "login");
            table.Rows.Add("btnAnnulation", "Annuler", "Cancel");
            table.Rows.Add("btnValidation", "Valider", "Save");
            table.Rows.Add("btnModification", "Modifier", "Update");
            return table;


Bala Murugan A.S [Syncfusion]
Replied On March 21, 2013 11:27 AM UTC

Hi Jaouen Cécile,

Thanks for using Syncfusion Products.

We regret for the inconvenience caused. We are unable to reproduce your reported issue in our end. We have created a simple sample to demonstrate this and the same can be downloaded from the below link.

sample: JsonDataTable.zip

Could you please replicate your issue in the above sample and send back to us so that we could able to sort out the cause of this issue and provide you a better solutions quickly?.

Please try the above sample and let us know if you have any concerns.


Bala Murugan A.S

Laszlo Boross
Replied On March 31, 2014 08:29 AM UTC

Thanks for this example Bala.

I am not having the same issue as Jaouen, but I am having difficulty with getting the Save action working when the Grid is bound to DataTable.

If I have a Grid bound to an Entity object, there is no problem, I run into all sorts of issues however when trying to edit a Grid bound to a data table, my SaveAction is always getting null result.

Is this the correct format?

public ActionResult JSONSave([Bind(Prefix = "updatedRecords")]DataTable orders)

I have also tried with IEnumerable<DataRow> and System.Data.DataRow without any luck

Can we please get an example where edit rows is working when bound to a System.Data.DataTable using ActionMode.JSON?

Silambarasan I [Syncfusion]
Replied On May 21, 2014 04:25 AM UTC

Hi Laszlo,


Thanks for using Syncfusion products.


We are glad to inform you that your requirement ("I am having difficulty with getting the Save action working when the Grid is bound to DataTable.") can be achieved by creating separate class for getting current record values and we suggest you to use the SetField method to update the current record values to the DataTable. Please refer the below code snippets.







//. . .   

.Editing(edit =>     




edit.PrimaryKey(new string[]{"OrderID"});          


.Mappers(map =>       








public ActionResult OrderSave(OrderClass order)


var dataTabl = GetTable();           

dataTabl.Rows.Find(order.OrderID).SetField("CustomerID", order.CustomerID);           

dataTabl.Rows.Find(order.OrderID).SetField("OrderDate", order.OrderDate);           

dataTabl.Rows.Find(order.OrderID).SetField("ShipCity", order.ShipCity);           

dataTabl.Rows.Find(order.OrderID).SetField("ShipPostalCode", order.ShipPostalCode);           


return dataTabl.AsEnumerable().GridJSONActions<System.Data.DataRow>();       



public DataTable GetTable()       


var connection = ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString;           

using (var dataAdapter = new SqlDataAdapter("SELECT * from Orders", connection))           


var dataTable = new DataTable();               


DataColumn[] key = new DataColumn[1];               

key[0] = dataTable.Columns["OrderID"];              

dataTable.PrimaryKey = key;               

return dataTable;           




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


Link: SampleProject.zip


Please let us know if you need any further assistance.




Silambarasan I


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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