I have 2 grids kept inside 2 seperate div tags: divAMGGrid, divSolveGrid.
divAMGGrid is having 1 grid with 2 levels. When I perform any operation on child level, I'll display second grid which is inside divSolveGrid. Till here it is working fine. But my requirement is to refresh 1st grid, when I perform any operation on 2nd grid which is in divSolveGrid. divAMGGrid is not refreshed with data. My aspx page is having following html inside RadAJAXManager:
<telerik:AjaxSetting AjaxControlID="divAMGGrid">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="divSolveGrid" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="divSolveGrid">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="divSolveGrid" />
</UpdatedControls>
</telerik:AjaxSetting>
Any help will be very much appreciated.
Thanks,
Kapil
7 Answers, 1 is accepted
It is obvious from the AjaxSettings that the 1st RadGrid updates the 2nd one, the 2nd one updates itself, but there is no setting, which says that the 2nd RadGrid should update the 1st one.
Best wishes,
Dimo
the Telerik team

Thanks for your reply, but I have tried putting the other settings also as mentioned below. But its not working out:
<telerik:AjaxSetting AjaxControlID="divAMGGrid">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="divSolveGrid" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="divSolveGrid">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="divAMGGrid" />
</UpdatedControls>
</telerik:AjaxSetting>
What I am understanding with this setting is that, it will make a loop to update Parent div then Child div then again Parent div and so on & so forth. How to achieve this? Please advice.
Thanks Again.
Kapil
Please inspect this demo.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
script
runat
=
"server"
>
protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
DataTable dt = new DataTable();
DataRow dr;
int colsNum = 2;
int rowsNum = 6;
string colName = "Column";
for (int j = 1; j <= colsNum; j++)
{
dt.Columns.Add(String.Format("{0}{1}", colName, j));
}
for (int i = 1; i <= rowsNum; i++)
{
dr = dt.NewRow();
for (int k = 1; k <= colsNum; k++)
{
dr[String.Format("{0}{1}", colName, k)] = DateTime.Now.ToLongTimeString();
}
dt.Rows.Add(dr);
}
(sender as RadGrid).DataSource = dt;
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
RadGrid2.Rebind();
}
protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
{
RadGrid1.Rebind();
}
</
script
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
id
=
"Head1"
runat
=
"server"
>
<
meta
http-equiv
=
"content-type"
content
=
"text/html;charset=utf-8"
/>
<
title
>RadControls</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
telerik:RadSkinManager
ID
=
"RadSkinManager1"
runat
=
"server"
Skin
=
"Vista"
/>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
/>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
DefaultLoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"panel1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"panel1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"panel2"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"panel2"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"panel1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"panel2"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
p
>Click on REFRESH in either RadGrid to see that both controls are updated</
p
>
<
p
>panel1</
p
>
<
asp:Panel
ID
=
"panel1"
runat
=
"server"
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
Width
=
"400px"
OnNeedDataSource
=
"RadGrid_NeedDataSource"
OnItemCommand
=
"RadGrid1_ItemCommand"
>
<
MasterTableView
CommandItemDisplay
=
"Top"
/>
</
telerik:RadGrid
>
</
asp:Panel
>
<
p
>panel2</
p
>
<
asp:Panel
ID
=
"panel2"
runat
=
"server"
>
<
telerik:RadGrid
ID
=
"RadGrid2"
runat
=
"server"
Width
=
"400px"
OnNeedDataSource
=
"RadGrid_NeedDataSource"
OnItemCommand
=
"RadGrid2_ItemCommand"
>
<
MasterTableView
CommandItemDisplay
=
"Top"
/>
</
telerik:RadGrid
>
</
asp:Panel
>
</
form
>
</
body
>
</
html
>
Best wishes,
Dimo
the Telerik team

Thanks for your reply. But scenario with me is a bit different. I need to reflect updated data in 2nd level of 1st grid when anything is changed on 2nd grid. Also, I am not saving data in database when any action is performed on 2nd grid. I am saving data in ViewState and then I have to bind the data with 2nd level of 1st grid. So if user feels that changes made at 2nd grid are good to be saved, he/she will click on Save button placed at 2nd level of 1st grid and update the DB accordingly. Else if he/she selects to Cancel, he/she can do that by clicking on the Cancel button placed at 2nd level of 1st grid. Hope you understood the problem. It is bit complicated to understand as well as to implement. Thanks again for your reply.
Regards,
Kapil Sharma
>> "Also, I am not saving data in database when any action is performed on 2nd grid. I am saving data in ViewState and then I have to bind the data with 2nd level of 1st grid."
This actually means that you still need to bind the first RadGrid again, however, you need to bind it to a temporary datasource, no matter where it is stored.
This task is not very much related to RadControls, but to algorithms.
Regards,
Dimo
the Telerik team

I am able to save the updated data in ViewState which is the datasource for 2nd level of first grid. This data is updated due to any change made on 2nd grid. When I try divAMGGrid.Rebind() it is not rebinding the data to the grid, but when I collapse & expand again a particular row, then i see updated data reflected in 2nd level of first grid. What am i missing here?
Thanks,
Kapil
It still seems you are missing an AJAX setting where divSolveGrid updates divAMGGrid. The easiest way to understand if this is the case is to disable AJAX completely. What happens when you remove all AJAX controls from the page. Do both grids behave as expected?
Veli
the Telerik team