Dear Telerik-Staff,
in my application, I have an aspx-Page which stores a RadGrid. In the RadGrid, each row has a column with a link. Clicking this link, opens a RadWindow which displays a custom user control (ASCX).
Inside this ASCX-Control I have another RadGrid, which displays data. I have implemented this and the window opens with the RadGrid. But when I want to sort (for example) data in the grid which is in the user control, the page only posts back and nothing happens. Let me show you, what I have done:
In my ASPX-Page:
The user control has been registered properly on the page head but I have skipped this since it is not relevant to my problem. The Code-behind of my ASPX-Page looks like this (again, only the relevant parts):
Ok, now. That works since the RadWindow shows up and displays the user control. The markup of the ascx-file looks like this:
The code behind of the ascx-control looks like this:
The Grid displays all the requested information that are retrieved by the "GetAppropriateData"-Method of a WebService instance. But when I try to sort the grid, it behaves as described above: The LoadingPanel is shown, a postback is raised and the grid is reloaded but not sorted.
In general: Any time, a postback is raised inside the RadGrid1 in my usercontrol, this control reloads making any sort, checkbox check, etc. lost.
I have spent so much time on this but I don't get the reason for this issue. When I transfer the code to a "simple" aspx-Page, everything runs as expected, but not for my usercontrol.
Could you please tell me what can cause my issue? I am totally stuck on this.
Best regards,
really appreciate your help,
Marco
in my application, I have an aspx-Page which stores a RadGrid. In the RadGrid, each row has a column with a link. Clicking this link, opens a RadWindow which displays a custom user control (ASCX).
Inside this ASCX-Control I have another RadGrid, which displays data. I have implemented this and the window opens with the RadGrid. But when I want to sort (for example) data in the grid which is in the user control, the page only posts back and nothing happens. Let me show you, what I have done:
In my ASPX-Page:
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" /> <telerik:RadSkinManager ID="RadSkinManager1" runat="server" Skin="Windows7"> </telerik:RadSkinManager> <telerik:RadAjaxPanel ID="contentPanel" runat="server"> <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AllowSorting="true" AllowPaging="false" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCommand="RadGrid1_ItemCommand"> <MasterTableView DataKeyNames="ID" ClientDataKeyNames="ID"> <Columns> <telerik:GridBoundColumn UniqueName="ID" DataField="ID" Visible="false"/> <telerik:GridBoundColumn DataField="Title" DataType="System.String" HeaderText="Title" SortExpression="Title" HeaderStyle-Width="200px"/> <telerik:GridBoundColumn DataField="Description" Visible="false"/> <telerik:GridTemplateColumn UniqueName="MyUniqueColumn" HeaderText="Custom Column" HeaderStyle-Width="150px"> <ItemTemplate> <asp:Button ID="btnShowUserControl" runat="server" Text="anzeigen" CommandName="CustomCommand"></asp:Button> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> <SortExpressions> <telerik:GridSortExpression FieldName="Title" SortOrder="Ascending" /> </SortExpressions> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> </ClientSettings> </telerik:RadGrid> </telerik:RadAjaxPanel> <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableViewState="false"> <Windows> <telerik:RadWindow ID="MyWindow" Title="My Title" Modal="true" runat="server" Behaviors="Close" EnableViewState="false" ReloadOnShow="true" ShowContentDuringLoad="false" VisibleStatusbar="false" Width="800px" Height="400px"> <ContentTemplate> <company:MyCustomControl ID="myCustomcontrol" runat="server"></company:MyCustomControl> </ContentTemplate> </telerik:RadWindow> </Windows> </telerik:RadWindowManager></asp:Content>The user control has been registered properly on the page head but I have skipped this since it is not relevant to my problem. The Code-behind of my ASPX-Page looks like this (again, only the relevant parts):
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "Customcommand") { try { //Get the requesting item GridDataItem itemToEdit = (GridDataItem)e.Item; //Init the user control MyCustomControl control = (MyCustomControl)MyWindow.ContentContainer.FindControl("myCustomcontrol"); control.MakeInit(new Guid(itemToEdit["ID"].Text), IDFromQueryString); MyWindow.VisibleOnPageLoad = true; } catch { } } }Ok, now. That works since the RadWindow shows up and displays the user control. The markup of the ascx-file looks like this:
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManagerProxy><telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /> <telerik:RadAjaxPanel ID="contentPanel" runat="server"> <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AllowSorting="true" AllowPaging="false" OnNeedDataSource="RadGrid1_NeedDataSource"> <MasterTableView> <Columns> <telerik:GridBoundColumn DataField="FirstID" Visible="false" /> <telerik:GridBoundColumn DataField="SecondID" Visible="false" /> <telerik:GridBoundColumn DataField="User.UserFullName" DataType="System.String" HeaderText="Full name of user" SortExpression="User.UserFullName" HeaderStyle-Width="200px"/> </Columns> <SortExpressions> <telerik:GridSortExpression FieldName="User.UserFullName" SortOrder="Ascending" /> </SortExpressions> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> </ClientSettings> </telerik:RadGrid></telerik:RadAjaxPanel>The code behind of the ascx-control looks like this:
private static Guid globalGuidID;private static int globalIntID = 0; protected void Page_Load(object sender, EventArgs e) { } public void MakeInit(Guid guidID, int intID) { globalGuidID = guidID; globalIntID = intID; RadGrid1.Rebind(); } protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { if (globalIntID > 0) { //Create service instance DataClient dataService = new DataClient(); RadGrid1.DataSource = dataService.GetAppropriateData(globalIntID); //Close service instance after usage dataService.Close(); } }The Grid displays all the requested information that are retrieved by the "GetAppropriateData"-Method of a WebService instance. But when I try to sort the grid, it behaves as described above: The LoadingPanel is shown, a postback is raised and the grid is reloaded but not sorted.
In general: Any time, a postback is raised inside the RadGrid1 in my usercontrol, this control reloads making any sort, checkbox check, etc. lost.
I have spent so much time on this but I don't get the reason for this issue. When I transfer the code to a "simple" aspx-Page, everything runs as expected, but not for my usercontrol.
Could you please tell me what can cause my issue? I am totally stuck on this.
Best regards,
really appreciate your help,
Marco