When a user edits a cell and I need to update a row, I need to know the old value that was there before (I cannot get it without the entire data set).
Right now as a hack I'm saving it in CellBeginEdit, but I'm hoping there's a better solution:
string oldValue;
private void deviceGrid_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
if (e.Column.Name == "DeviceName")
{
oldValue = e.Row.Cells["DeviceName"].Value.ToString();
}
}
private void deviceGrid_CellEndEdit(object sender, GridViewCellEventArgs e)
{
if (e.Column.Name == "DeviceName")
{
string newName = e.Value.ToString();
Device device = Program.SapphireService.GetDeviceXmlByID(oldValue);
Program.SapphireService.UpdateDevice(device, newName);
}
}