开发者

Update DataKeyNames field value in gridview

开发者 https://www.devze.com 2022-12-15 13:11 出处:网络
I am using gridview for add and update process in database. Process Flow: Name A  B  C&开发者_JS百科nbsp;Command

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

  1. The first record does not have value in datakey field because there is no record in the database
  2. The Second record has data key because it has the record available.
  3. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号