Wednesday 28 March 2007

GridView : Getting updated cell values

When using a gridview the RowUpdating event arguments has a property (e.)NewValues.
There is a problem if the GridView datasource is not set to s DataSourceObject, these NewValues remain blank.
To populate use the following code:
GridView gv = (GridView)sender;
for (int i = 0; i < gridView.Columns.Count; i++)
{
DataControlFieldCell cell = gv.Rows[e.RowIndex].Cells[i] as DataControlFieldCell;
gv.Columns[i].ExtractValuesFromCell(e.NewValues, cell, DataControlRowState.Edit, true);
}