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

Best practice for auto generated primary key

Thread ID:





111008 Sep 3,2013 11:22 PM UTC Sep 17,2013 09:19 AM UTC ASP.NET MVC (Classic) 2
Tags: Grid
Jeremy Branham
Asked On September 3, 2013 11:22 PM UTC

What is the best practice for using a grid with a domain object that has an auto-generated primary key?
Setting the column to read-only or editable=false doesn't work because the field is still rendered.
In my case I am using NHibernate, and the primary key needs to be passed as NULL to create a new record.
Because the grid is expecting the primary key to be required, it will not allow a 'new item' form to be submitted unless the field has a value.
But if the field has a value, then NHibernate tries to update a record based on the primary key entered.
So as a workaround, I use a nullable int as the type for the primary key.
I feel there is a better way...
Anyone have a better idea?

Jeremy Branham
Replied On September 4, 2013 12:35 AM UTC

So I can use the client event "OnActionSuccess" to hide the field, then the validation is not fired.

gridbuilder.ClientSideEvents(events =>


This is an acceptable workaround.

Eswari S [Syncfusion]
Replied On September 17, 2013 09:19 AM UTC

Hi Customer,


Happy to hear that your issue has been solved by workaround.


Please let us know if you need  any other assistance.



Eswari S


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

This page will automatically be redirected to the 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