I am trying to do an insert in editForm in a RadGrid nested in another RadGrid's editform. I need a way to tell the parent grid to close its editForm.
I have a RadGrid (RadGridMain) that lets the user display and edit some data. It works fine for update and delete.
In order to do inserts and updates using slightly different processes, I have an Edit.ascx and an Insert.ascx. The OnItemCommand adjusts the user control appropriately like:
protected void RadGridMain_OnItemCommand(object sender, GridCommandEventArgs e)
if (e.CommandName == RadGrid.InitInsertCommandName)
RadGridMain.MasterTableView.EditFormSettings.UserControlName = "~/Insert.ascx"
// Set up the control
Control control = Page.LoadControl("~/Insert.ascx");
RadGrid radGridInsert = control.FindControl("radGridInsert") as RadGrid;
radGridInsert.NeedDataSource += RadGridInsertSelector_OnNeedDataSource;
// give the child a handle to the parent
PSC.Controls.UdcsConnectionInsert.ParentRadGrid = RadGridMain;
else if (e.CommandName == RadGrid.EditCommandName)
RadGridMain.MasterTableView.EditFormSettings.UserControlName = "~/Edit.ascx";
The reason that I am loading the insert control and assigning the NeedDataSource is that I am doing this in SharePoint, and this seems to be the best way.
So, the insert.ascx control gives the user a RadGrid (let's call it radGridInsert) to select an item to associate with and then opens up an editform in radGridInsert to do the insert. Once the insert is done, they click Save and the RadGridInsertSelector editform closes. This works great.
The catch is that when they save or cancel in the radGridInsert editForm, I want to tell the outer RadGrid (RadGridMain) to stop editing and close its editform. The only way that I have been able to do it so far is by having a button that calls the cancel command in the ascx outside the RadGridInsertSelector.
In the radGridInsert_OnInsertCommand, I can save the data and close the radGridInsert editform, but I need a way to pass this to the parent so that it closes its editform.
In radGridInsert_OnInsertCommand, I have tried calling
ParentRadGrid.MasterTableView.IsItemInserted = false;
GridEditFormItem editFormItem = e.Item as GridEditFormItem;
GridDataItem parentItem = editFormItem.ParentItem;
parentItem.EditFormItem.Edit = false;
Any suggestions would be greatly appreciated.