I have usercontrol in which 'RadDockLayout','RadDockZone' and 'RadDock' is defined. Now this usercontrol is binded with in datalist. So for each row these three controls will loaded dynamically.
Now, My question is, how to maintain RadDock state (Collapse/Expand) at each postback?
Please respond ASAP... Thanks
11 Answers, 1 is accepted
Please reply on this question ASAP.
I have some suggestions for configuring the docks scenario correctly. The RadDockLayout control is designed to persist the state of all RadDocks on the page so you need only one layout control on the page and it should wrap all docks.
If the user control that contains the docks is loaded from the code-behind, please add it on Page_Init to ensure that all controls are initialized correctly and their state is persisted.
As for the Collapse/Expand state, it is automatically persisted through postbacks in the client state of the dock control. If you want to keep it when the page is reloaded or closed and opened again, you can use the events SaveDockLayout and LoadDockLayout of RadDockLayout. You can check an example in this online demo.
the Telerik team
Thanks for Reply.
My scenario is different than you have stated. I have usercontrol in which 'RadDockLayout', 'RadDockZone' and 'RadDock' are loaded. Following is the code for the same
<telerik:RadDockLayout ID="RadDockLayout1" runat="server" EnableViewState="true"
<telerik:RadDockZone BorderStyle="None" ID="RadDockZone1" runat="server">
<telerik:RadDock ID="RadDock1" runat="server" OnCommand="RadDock_Command">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Text")%>'/>
<asp:DataList runat="server" ID="DataList1" RepeatColumns="3" RepeatDirection="Horizontal" CellPadding="5">
Text='<%# Bind("Name") %>' runat="server" Enabled="true" OnClick="LinkButton1_Click" />
<telerik:DockCommand Text="Save Position" AutoPostBack="true" />
This usercontrol will load from following aspx page.
<telerik:RadPane ID="RadPane1" runat="server">
<asp:DataList id="DataList2" runat="server" OnItemDataBound="DataList2_ItemDataBound" DataKeyField="Text">
<ccg:UControl1 ID="Uctrl1" runat="server" />
protected void DataList2_ItemDataBound(object sender, DataListItemEventArgs e)
DataListItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
DataSet Dataset1 = new DataSet();
int rowCount = 0;
System.Data.DataRow result = Dataset1.Tables.Select("Type='Type1' OR Type='Type2'");
DataTable1 = Dataset1.Tables.Clone();
DataTable2 = Dataset1.Tables.Clone();
foreach (System.Data.DataRow row in result)
while (rowCount <= DataTable1.Rows.Count - 1)
if (DataTable1.Rows[rowCount]["Type"].ToString() == "Type1")
if (((DataRowView)(item.DataItem)).Row.ItemArray.ToString() == DataTable1.Rows[rowCount]["Text"].ToString())
while (DataTable1.Rows[rowCount + 1]["Type"].ToString() == "Type3")
DataTable2.Rows.Add(DataTable1.Rows[rowCount + 1].ItemArray);
rowCount = rowCount + 1;
if (rowCount == DataTable1.Rows.Count - 1)
UControl1 reportDetails = item.FindControl("Uctrl1") as UControl1;
reportDetails.reportDataTable = DataTable2;
reportDetails.reportDomain = DataTable1.Rows[rowCount]["Text"].ToString();
rowCount = rowCount + 1;
The scenario is, usercontrol is loaded in datalist_itemdatabound event. So for each item new 'RadDockLayout', 'RadDockZone' and 'RadDock' is loaded.
The problem is when page is loaded, ' RadDock_LoadDockLayout' is not called for dock. So when user collapse any dock and try to save settings, the dock is expanded again and not able to save its state.
RadDockLayout should be added on the page before the event ItemDataBound of the DataList is fired. The dock layout control depends on events that are raised early on the page lifecycle (Init event). In your case the dock layout is included in the user control which is loaded too late and the event LoadDockLayout is not fired.
The suggested approach in this case is remove the RadDockLayout from the user control and place it on the page Default.aspx so that it wraps all user controls that contain docks. The purpose is to use a single dock layout control for persisting the state of all docks on a page.
the Telerik team
I have tried to remove the RadDockLayout from the user control and place it on the page Default.aspx, and place RadDockZone and RadDock in usercontrol, but it gives me error "RadDockLayout should contain raddockzone"
If I place RadDockLayout and RadDockZone in Default.aspx, and RadDock in usercontrol so it give me error "RaddockZone should contain RadDock".
If you have some samples for above scenario, then please share with us.
Please find attached the required example.
the Telerik team
In example there is only one dock loaded at a time so there is no any problem with that. In my case no of docks are decided at runtime so I need to bind usercontrol in datalist.
If I follow this approach, I received error "The ID of RadDock with ID='XXX' is not unique to RadDockLayout with ID='YYY'. Please, set the UniqueName property of RadDock with ID='XXX' with a value, which is unique to RadDockLayout with ID='YYY'".
Can you please provide example with using of datalist or any list in which usercontrol is binding?
May be you should post your code here, that would make it easier for everyone willing to help you. And please, MF please, use the CodeBlock format when you do.
As Slav said, 1 dock layout per page is definitely the best approach and the most efficient.
Post your code and I'll have a look see if I can be of any help here.
I have already attached code in my earlier post. See if it helps you else I will again upload code.
Please use the code block format, it makes it way easier to read for us.