Alright, from what I can tell, when using the Typed Data Sources, adding new records works as expected without any additional code. The updates and deletes required special handlers... here's what I had to do.
protected void UltraWebGrid1_UpdateRowBatch(object sender, RowEventArgs e)
{
if (!(e.Row.Cells.FromKey("Id").Value is Int64)) return;
MyService service = new MyService();
MyEntity entity = service.GetById(
(long)e.Row.Cells.FromKey("Id").Value);
Hashtable hash = new Hashtable();
foreach (UltraGridCell cell in e.Row.Cells)
{
hash.Add(cell.Key, cell.Value);
}
MyDataSource.Update(entity, hash);
}
protected void UltraWebGrid1_DeleteRowBatch(object sender, RowEventArgs e)
{
MyService service = new MyService();
MyEntity entity = service.GetById(
(long)e.Row.Cells.FromKey("Id").Value);
MyDataSource.Delete(entity);
}
This explicitly updates and deletes rows as needed for the batched updates/deletes that the grid sends on postback. The first line in the update batch routine... I'm still not sure why it is needed, but if you don't have it, it can cause your transaction to be rolled back because it sends an extra update occasionally (with some random objects as cell values... yikes). So, I just made sure that the Id cell matches the entity Id type before continuing with the update. Everything else here is fairly self explanatory.
Hopefully, this will help someone... and hopefully, someone will tell me there is a better way! Geesh.
Thanks,
Marc