Silverlight 4 - MVVM - Domain Service Primary Key is always "0" in datagrid
We have a sql server database with primary key (as identity column) and we have followed MVVM model to insert the database records. We have a Data Grid binded with View Model to display the results. We are successfull in inserting the new records but Data Grid is not refreshing the primary key (int) field, in another words in the data grid the primary key value is always stays zero (0) until we refresh the screen; which is causing exception when we try inserting another record. Please help.
Thank yo开发者_如何学Cu.
Regards, Siva
In order to get the primary key information I believe you actually have to requery the database. You are inserting the records, but you have to refresh your model from the database to get the new primary keys since its a function of the the database to create it.
精彩评论