Last post Apr 22, 2014 12:14 AM by Sam - MSFT
Apr 21, 2014 09:11 AM|vignesht5|LINK
I have a gridview in a page and also I have a update button which does bulk update for gridview. I have 5 columns in my gridview out of which first 3 columns are not editable and last two columns have dropdown values.
If I change any one dropdown in a page and click update it saves all the rows of that page. I need to capture only selected row values and update only that row item. Also on top of this how can I capture the old values of that two dropdown and save it in
a seperate table which is called the history table. Can anyone advice or suggest me to achieve this?
Apr 22, 2014 12:14 AM|Sam - MSFT|LINK
If I change any one dropdown in a page and click update it saves all the rows of that page. I need to capture only selected row values and update only that row item. Also on top of this how can I capture the old values of that two dropdown and save it in a
seperate table which is called the history table.
Things are bit complex in your scenario as you are NOT using the GridView Selection Events. You may consider using GridView's SelectedIndexChanged events.
So, my suggestion would be to use combination of two events. First enable the Select Button in the GridView.
Let the user select the row to be updated
> use the GridView SelectedIndexChanged to save all the selected values to Session
> Then change the value and update the DataBase with new record using the DropDownList SelectedIndexChanged as the selected row data is already in Session Variable it won't be a issue
> Save the Session Data (which is previous data to the history table)
You may also considet using DataView.
You can use the
RowStateFilter property to specify which row versions to view. The DataView implicitly manages which row version to expose depending upon the RowState of the underlying row. For example, if the
RowStateFilter is set to DataViewRowState.Deleted, the
DataView exposes the Original row version of all
Deleted rows because there is no Current row version. You can determine which row version of a row is being exposed by using the
RowVersion property of the DataRowView.
The Current row version of all Unchanged,
Added, and Modified rows. This is the default.
The Current row version of all Added rows.
The Original row version of all Deleted rows.
It can be very handy. Just refer to it and see if it helps.Sorting and Filtering Data -
Hope it helps!