I have a scenario where there are two divs on a page. One contains a RadGrid. Both are setup in the RadAjaxManager to only update themselves, not each other. My problem occurs when the non-Grid div is causing a post back, I select some items in the RadGrid but once the postback completes, my selected items in the grid are cleared. How do I prevent this?
Here is a real basic example of my setup:
Just load a couple items into the grid on page load and put a sleep for a couple seconds when the page is posted back. In order to reproduce: Click the non-grid button, quickly select an item in the grid by clicking the check box, notice that the selection is removed when the ajax response returns.
If I remove the divGrid from being declared in the ajax manager, the grid retains its selected items even when selected during the ajax postback.
Here is a real basic example of my setup:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Grid.aspx.cs" Inherits="TelerikTest.Grid" %> <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="scriptManager" runat="server"></telerik:RadScriptManager> <telerik:RadAjaxManager ID="ajaxManager" runat="server" DefaultLoadingPanelID="ajaxLoadingPanel" > <AjaxSettings> <telerik:AjaxSetting AjaxControlID="divGrid"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="divGrid" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="divNonGrid"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="divNonGrid" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="ajaxLoadingPanel" runat="server" Skin="" Transparency="20" > <div id="Div1" style="background-color: #F0F0F0; height:100%; width:100%;" runat="server"></div> </telerik:RadAjaxLoadingPanel> <div> <div id="divNonGrid" runat="server"> <asp:Button ID="btnNonGrid" runat="server" Text="non-grid" /> </div> <div id="divGrid" runat="server"> <asp:Button ID="btnGrid" runat="server" Text="grid" /> <telerik:RadGrid ID="RadGrid1" runat="server"> <MasterTableView> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridClientSelectColumn UniqueName="column"> </telerik:GridClientSelectColumn> <telerik:GridBoundColumn UniqueName="ID" DataField="ID" > </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="column1"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="column2"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="True" /> </ClientSettings> </telerik:RadGrid> </div> </div> </form> </body> </html> Just load a couple items into the grid on page load and put a sleep for a couple seconds when the page is posted back. In order to reproduce: Click the non-grid button, quickly select an item in the grid by clicking the check box, notice that the selection is removed when the ajax response returns.
If I remove the divGrid from being declared in the ajax manager, the grid retains its selected items even when selected during the ajax postback.