Get DataSet in RowCommand event/Get modified rows in RowCommand
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.
精彩评论