I have a 3 level hierarchical grid in page Grid.aspx. After expanding my grid to third level, I click on Add New Record, which opens a UserControl ( UsrCntrl1.ascx) as add template. This usercontrol contains a grid, a combo and a button (name is 'Add to grid') inside it.
In the usercontrol, when i select a value in the combobox and click on button 'Add to Grid', a server side function is called which updates rad grid datatable by adding a new row to it and then binding the grid again. After the addition process is complete, the grid is successfully updated with new row, but when this usercontrol(UsrCntrl1.ascx) finishes its postback and rebinds itself to the 3 level hierarchical grid an error occurs saying,
"Microsoft JScript runtime error: Sys.InvalidOperationException: A control is already associated with the element."
The Grid UI Code in UsrCntrl.ascx:
<rad:RadGrid ID="DynamicList" runat="server" ></rad:RadGrid>
The Grid Codebehind Code in UsrCntrl.ascx.cs:
void AddToList(object sender, ImageClickEventArgs e)
dt = new DataTable();
if (Session["List"] == null)
dt = (
DataRow dr = dt.NewRow();
DynamicList.DataSource = dt;
"List"] = dt;
What is causing this error ? I have already checked that there is no naming / ID conflicts between the grid page and template(usercontrol) page.