GridView and Updating
Hi guys,
I am new to GridViews.. I have a gridview that displays 3 columns.
Description, MahUsed and a calculated % Used field.
When I click Edit on the row, the MahUsed goes into Edit mode, and I
can change the value.
Now the problems start.
I click 'Update', and I end up with the original value.
The ObjectDataSource has an Update method, that points to this
function:
public void UpdatePackUsage(int Id, int Mahusage)
{
dbfb.UpdatePackUsage(Id, Mahusage);
}
If I put a breakpoint on this function, it is getting hit, however,
the value for Mahusage is always the ORIGINAL value. That is, it never
changes to what I have typed in the edit box.
Do I need to use the RowUpdating event? I'm not at the moment, but am
wondering if I need to do something like:
protected void GridView1_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
FlightBatteryService fbs = new FlightBatteryService();
fbs.UpdatePackUsage(int.Parse(e.Keys["Id"].ToString()),
int.Parse(e.NewValues["Mahusage"].ToString()));
DataBind();
}
I tried that, and removed the UpdateMethod from the ODS, but then I
get an error about requiring an update method if editing is to be
used.
Hope someone can assit. |