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.

Best practice for auto generated primary key

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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 3, 2013 08:35 PM

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

gridbuilder.ClientSideEvents(events =>
{
events.OnActionSuccess("onsuccess");
})    

 

This is an acceptable workaround.


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

Hi Customer,

 

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

 

Please let us know if you need  any other assistance.

 

Regards,

Eswari S


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.

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.

;