This question is locked. New answers and comments are not allowed.
I am trying to create a status column that shows yellow when a record update is being pushed to the server, and changes to green when the update is complete, but am having trouble. The following is my code...
public void dg_RowLoaded(object sender, RowLoadedEventArgs e) { |
e.Row.Cells[0].Content = (dg.Items.IndexOf(e.Row.Item) + 1).ToString(); |
} |
public void dg_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e) { |
if (e.EditAction == GridViewEditAction.Commit) { |
e.Row.Cells[0].Background = new SolidColorBrush(Colors.Yellow); |
_ws.SetContactCompleted += new EventHandler<ServiceReference1.SetContactCompletedEventArgs>(_ws_SetContactCompleted); |
_ws.SetContactAsync((ServiceReference1.Contact)e.Row.Item); |
} else { |
dg.CancelEdit(); |
} |
} |
public void _ws_SetContactCompleted(object sender, ServiceReference1.SetContactCompletedEventArgs e) { |
int iIndex = dg.Items.IndexOf(e.Result); |
DependencyObject iDO = dg.ItemContainerGenerator.ContainerFromIndex(iIndex); |
} |
In dg_RowEditEnded I pass a Contact to the webservice to be updated, and after update it returns the same Contact back in e.Result in the _ws_SetContactCompleted method. However, when I call IndexOf it returns -1. I have checked the passed and return values from the webservice, and it is the exact same object.
Any help is much appreciated.
Thanks