I want to manually modify an entity during a callback. It seems to work, but there is a bit of weirdness at the end.
I'm using a Developer Express ASPxDataView control, and inside of it is an ASPxRadioButtonList. When the user changes the selection in the latter, I force a callback, so I can change the associated field in the entity. Here's the callback handler:
protected void uiDataView_CustomCallback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
LocationEntity location = (LocationEntity)locationsDS.EntityCollection[uiDataView.PageIndex];
location.LocationStatusID = int.Parse(e.Parameter) + 1;
location.DBA = location.DBA + " (CHANGED)";
manager.Save(location);
location = (LocationEntity)locationsDS.EntityCollection[uiDataView.PageIndex];
}
This works, the entity is the correct one, and I've confirmed the changes are saved to the database. However, later when I page back to this entity, it appears that an older copy of the entity is still hanging around. Below is my method GetSelectedIndex() which is called by the radio button list control to determine what SelectedIndex should be.
protected int GetSelectedIndex()
{
LocationEntity location = (LocationEntity)locationsDS.EntityCollection[uiDataView.PageIndex];
return location.LocationStatusID - 1;
}
The entity I get here from locationsDS.EntityCollection, using the same index (believe me, I'm making sure!) has the old values for the fields, not what's currently in the database. If I refresh the page, I see the new values.
I've tried doing various things, like setting locationsDS.Refetch to true, followed by Databind() on the control, etc., but nothing works.