0

I am trying to update a row in a Gridview control whilst it is in edit mode.
I am trying to extract the old data field values which have not changed during the edit process, but can't seem to find them, as the postback after clicking the edit button removes those values.
Any idea on how I can extract the values contained in the cells of a specific row before going into edit mode
Thanks

2
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by nakor77
0

are you trying to get the values before the gridview switches to edit mode or do you need to get the values before applying any updates to to the data? Say you click edit, now you get some input controls, you change a couple of values, then click update. Are you wanting the old values before the edit or before the update?

Edited by nakor77: n/a

0

I am not sure. I want the values of the unupdated fields for the same record.

0

I want the data from the edit controls before they are posted back and refilled with old data. After having edited them but before updating them.

0

Then you should be able to use the GridView's OnUpdating event. This event occurs just before the data is sent to the database to be updated. The method will look something like

protected void GridView_OnUpdating(object sender, GridViewUpdateEventArgs e)
{

}

in the code behind. The parameter "e" will have two properties that you should be able to use. One called NewValues and one called OldValues.

protected void GridView_OnUpdating(object sender, GridViewUpdateEventArgs e)
{
    string value = e.NewValues["column_name"].ToString(); // would get one of the updated values

    string old = e.OldValues["column_name"].ToString(); // would get the original value
}

Edited by nakor77: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.