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
close icon

Autoincrement column not updating on insert


I am struggeling to use the MVC Grid when I try to insert a row with an Autoincrement Column. The Grid works o.k. when updating and deleting a row. However, when I insert a new row, the Autoincrement Column remains empty in the Grid. The autoincrement column is marked with the isIdentity and the isPrimaryKey attributes:


I use a remoteSaveAdaptor to do the updates:

        .Datasource(ds => ds.Json((IList<Fehlzeiten.Models.SystemUser>)ViewBag.datasource).Adaptor(AdaptorType.RemoteSaveAdaptor).InsertURL("DialogInsert").UpdateURL("DialogUpdate").RemoveURL("DialogDelete"))

 and when Inserting the Row  I use a Controller Method to update the database. The controller method is very simple:

         public ActionResult DialogInsert(Fehlzeiten.Models.SystemUser value)
            int val = value.Insert();  // val contains the Autoincrement ID of the newly created Row 
            var data = value.GetList();  // This returns an IList<object>
            return Json(data, JsonRequestBehavior.AllowGet);

The variable data in the controller method "DialogInsert" contains all rows from the database including the newly created row. How can I refresh the DataSource of the grid, so that the new Row will be completely shown in the grid - including the Autoincrement value?

Is there somewhere a sample how this is done?

3 Replies

AR Ajith R Syncfusion Team March 31, 2015 06:14 PM UTC

Hi Holger,

Thanks for using Syncfusion products.

Query : How can I refresh the DataSource of the grid, so that the new Row will be completely shown in the grid - including the Autoincrement value?

We are sorry to let you know that we are unable to reproduce your reported issue. We suspect that you have not set the IDENTITY to the corresponding data field in your database which is the cause of the issue. We have to compute the set of modified inserted objects in the database by using SubmitChanges function for the auto increment value. Please refer the below code snippet for further details.


[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_OrderID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]

public int OrderID






public ActionResult DialogInsert(OrdersView value)


var ds = new NorthwindDataContext();



var jsonData = OrderRepository.GetEditable(value);

return Json(jsonData, JsonRequestBehavior.AllowGet);


For your convenience we have created a simple sample and the same can be downloaded from the below link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/118664/IdentityRemoteUrlGrid-161444319.zip

Please let us know if you have any concerns.


Ajith R

HS Holger Schade April 1, 2015 02:56 PM UTC

Hello Ajith,

I checked your sample and it works. However you are using an Entity Framework Datamodel or Linq to SQL with the respective attributes. For some reasons this is not possible for me, as I accessing the database by pure ADO.NET. 

Anyhow I now used a workaround by reloading the Grid with the ClientSideEvent EndAdd. So I modified the grid

        .ClientSideEvents(ev => ev.EndAdd("endAddFunc"))

and added the following script:

    <script type="text/javascript">
           function endAddFunc() {

which works perfectly well. Thanks for your effort.

AR Ajith R Syncfusion Team April 2, 2015 06:06 AM UTC

Hi Holger,

Thanks for your update.

We are happy to hear that your requirement has been achieved in your end.

Please get back to us if you have any other concerns.

Ajith R

Live Chat Icon For mobile
Up arrow icon