Hi,
I have a page which displays a master record and contains one or more grids which display child records. The grids use user controls for displaying the data in edit mode.
If a user saves the master record (by clicking a SAVE button) while one of the child grids is still in edit mode, I would like to save the child grids automatically, ie find out if they are in edit or insert mode, retrieve the control values from the usercontrol and call insert/update on the data model (after validation).
If the insert/update is triggered by an event (Button Click), it is handled as follows:
protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
//Get the GridEditableItem of the RadGrid
GridEditableItem editedItem = e.Item as GridEditableItem;
....
What I would like to to when the master record is saved:
protected void btnSave_Click(.....) //Save event of master record
{
...Save master record...
If (childGrid.IsInEditMode)
{
GridEditableItem editedItem = childGrid.GetCurrentEditableItem(); //How can this be achieved
ChildObject co = GetData(editableItem):
if (editableItem.IsInInsertMode()) //How can this be achieved
{
datamodel.insert(co):
}
else
{
datamodel.update(co);
}
}
}
Any help would be greatly appreciated.
Thanks,
Stefan