开发者

Get DataSet in RowCommand event/Get modified rows in RowCommand

开发者 https://www.devze.com 2022-12-11 00:31 出处:网络
I am trying to get the dataset in RowCommand event. Like this: D开发者_C百科ataTable dt = (DataTable)(gvImages.DataSource);

I am trying to get the dataset in RowCommand event. Like this:

D开发者_C百科ataTable dt = (DataTable)(gvImages.DataSource);
DataTable dtChanges =  dt.GetChanges(DataRowState.Modified);

But my dataTable returns NULL.

Can any one help me find the modified rows in the RowCommand event?


Store the Datatable in the Session or ViewState. Retrieve it and modify it based on user selected row and change then save back to session. On the Rowcommand you will be able to retrieve the changes because they will be stored in the session/viewstate.


See the answers to this question. Basically, the underlying datasource used by a GridView is not saved in the view state, which means it is unavailable during a post back. If you need access to the data source, you must cache it yourself.

0

精彩评论

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