I am using gridview for add and update process in database.
Process Flow:
Name A B C &开发者_JS百科nbsp;Command
xx Add
yy 12 13 13 Update
zz 22 33 44 Update
- The first record does not have value in datakey field because there is no record in the database
- The Second record has data key because it has the record available.
- I want to update the datakey field value of the gridview after add process done
I'm not sure if this is what you're asking about; but the row's DataKey field in a GridView is updated every time you bind the GridView to a data source, calling the DataBind()
method.
So, after you have added a new record, just load the data source and bind the GridView to it, and the DataKey fields will have the new values.
精彩评论