Hi,
I have a rad button inside a command item template of a rad grid. This button is used to show/hide the filter row of the grid. My problem is that the button seems to lose its toggle state on post back.
For example, if the current toggle state index of the button is 1 and then I do any action that causes a post back, the toggle state index of the button reverts back to 0. How can I get it to maintain the same selected index.
Below is my code.
Thank you for your help.
Tracy
I have a rad button inside a command item template of a rad grid. This button is used to show/hide the filter row of the grid. My problem is that the button seems to lose its toggle state on post back.
For example, if the current toggle state index of the button is 1 and then I do any action that causes a post back, the toggle state index of the button reverts back to 0. How can I get it to maintain the same selected index.
Below is my code.
Thank you for your help.
Tracy
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb" Inherits="IPS_Gateway.WebForm2" %><!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></title></head><script type="text/javascript"> function ShowHideFilter(sender, args) { var radGrid = $find("<%= rgvMainGrid.ClientID %>"); var masterTable = radGrid.get_masterTableView(); var toggleList = sender.get_selectedToggleStateIndex(); switch (toggleList) { case 0: sender.set_toolTip('Show Filter Row'); masterTable.hideFilterItem(); break; case 1: sender.set_toolTip('Hide Filter Row'); masterTable.showFilterItem(); break; }}</script><body onkeydown="javascript:if(window.event.keyCode == 13) window.event.keyCode = 9;" > <form id="form1" runat="server"> <act:ToolkitScriptManager ID="tsmManager" runat="server" EnablePartialRendering="true" AsyncPostBackTimeOut="600" /> <telerik:RadAjaxManager ID="ajaxManager" runat="server" > <ClientEvents /> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="rgvMainGrid" > <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="rgvMainGrid" LoadingPanelID="ralpTimer" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="ralpTimer" runat="server" Skin="WebBlue" EnableEmbeddedSkins="true" BackgroundPosition="Center" > <wuc5:TimerControl ID="wucTimer" runat="server" /> </telerik:RadAjaxLoadingPanel> <asp:SqlDataSource ID="SQLDS_ArgusDBID" runat="server" ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>" SelectCommandType="StoredProcedure" SelectCommand="[Company].[DSP_CompanyMaster-Sel-Ins-Upd-Del]" /> <asp:SqlDataSource ID="SQLDS_SecurityType" runat="server" ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>" SelectCommandType="StoredProcedure" SelectCommand="[Security].[DSP_SecurityIdentifiers-Sel-Ins-Upd-Del]" /> <asp:SqlDataSource ID="SQLDS_SecurityUsers" runat="server" ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>" SelectCommandType="StoredProcedure" SelectCommand="[Security].[DSP_SecurityUsers-Sel-Ins-Upd-Del]" /> <asp:SqlDataSource ID="SQLDS_SavedSettings" runat="server" ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>" SelectCommandType="StoredProcedure" SelectCommand="[System].[DSP_SavedSettings-Sel-Ins-Upd-Del]" /> <asp:UpdatePanel ID="uppGrid" runat="server" UpdateMode="Conditional"> <ContentTemplate> <telerik:RadGrid ID="rgvMainGrid" runat="server" DataSourceID="SQLDS_SecurityUsers" EnableEmbeddedSkins="true" Skin="Office2010Silver" Height="550px" Width="1230px" EnableViewState="true" AutoGenerateColumns="false" AllowMultiRowSelection="false" AllowFilteringByColumn="true" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true" AllowAutomaticDeletes="false" AllowAutomaticInserts="false" AllowAutomaticUpdates="false" AllowSorting="true" EnableLinqExpressions="false" AllowPaging="true" PageSize="100" > <ItemStyle Wrap="false" /> <AlternatingItemStyle Wrap="false" /> <ActiveItemStyle BackColor="CornflowerBlue" /> <HeaderStyle HorizontalAlign="Center" /> <PagerStyle AlwaysVisible="true" Mode="NextPrevNumericAndAdvanced"/> <EditItemStyle BackColor="CornflowerBlue" /> <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true" EnablePostBackOnRowClick="false" EnableRowHoverStyle="false" > <ClientEvents /> <Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true" AllowRowResize="false"/> <Selecting AllowRowSelect="true" /> <Scrolling AllowScroll="true" UseStaticHeaders="true" /> </ClientSettings> <GroupHeaderItemStyle Font-Size="11px" Font-Names="calibri" Font-Bold="true" Height="12px"/> <ExportSettings Excel-FileExtension="xls" Excel-Format="Biff" OpenInNewWindow="true" ExportOnlyData="true" IgnorePaging="true" UseItemStyles="true"> </ExportSettings> <MasterTableView Name="Users" DataSourceID="SQLDS_SecurityUsers" DataKeyNames="UserID" ClientDataKeyNames="UserId" Width="1213px" EnableViewState="true" EditMode="InPlace" CommandItemDisplay="Top" > <CommandItemTemplate> <div style="padding: 1px 0px 7px 0px;height:18px;"> <telerik:RadButton ID="rbtAdd" runat="server" SkinId="skn_RadGrid_Add" CommandName="InitInsert" /> <telerik:RadButton ID="rbtEdit" runat="server" SkinId="skn_RadGrid_Edit" CommandName="EditSelected" /> <telerik:RadButton ID="rbtDelete" runat="server" SkinId="skn_RadGrid_Delete" CommandName="DeleteSelected" /> <telerik:RadButton ID="rbtCancel" runat="server" SkinId="skn_RadGrid_Cancel" CommandName="CancelAll" /> <telerik:RadButton ID="rbtSaveNew" runat="server" SkinId="skn_RadGrid_Save" CommandName="PerformInsert" /> <telerik:RadButton ID="rbtSave" runat="server" Skinid="skn_RadGrid_SaveNew" CommandName="UpdateEdited" /> <div style="position:absolute;left:1037px;"> <telerik:RadButton ID="rbtFilters" runat="server" SkinId="skn_RadGrid_Filter" ButtonType="StandardButton" ToggleType="CustomToggle" AutoPostBack="false" EnableViewState="true" OnClientToggleStateChanged="ShowHideFilter" > <ToggleStates> <telerik:RadButtonToggleState PrimaryIconUrl="<%$ Resources:Images,FilterExpand16%>" /> <telerik:RadButtonToggleState PrimaryIconUrl="<%$ Resources:Images,FilterCollapse16%>" /> </ToggleStates> </telerik:RadButton> </div> </div> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn DataField="UserId" UniqueName="UserId" HeaderText="Id" HeaderStyle-Width="60px" SortExpression="UserId" FilterControlWidth="40px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" ReadOnly="true" /> <telerik:GridBoundColumn DataField="EmployeeLogin" UniqueName="EmployeeLogin" HeaderText="Login Id" HeaderStyle-Width="150px" SortExpression="EmployeeLogin" FilterControlWidth="130px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" /> <telerik:GridBoundColumn DataField="EmployeeNumber" UniqueName="EmployeeNumber" HeaderText="Emp #" HeaderStyle-Width="80px" SortExpression="EmployeeNumber" FilterControlWidth="60px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" ReadOnly="true" /> <telerik:GridBoundColumn DataField="UserName" UniqueName="UserName" HeaderText="User Name" HeaderStyle-Width="190px" SortExpression="UserName" FilterControlWidth="170px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" /> <telerik:GridBoundColumn DataField="EmailAddress" UniqueName="EmailAddress" HeaderText="Email Address" HeaderStyle-Width="190px" SortExpression="EmailAddress" FilterControlWidth="170px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" /> <telerik:GridDropDownColumn DataField="SecurityType" UniqueName="SecurityType" HeaderText="Sec Type" HeaderStyle-Width="100px" SortExpression="SecurityType" FilterControlWidth="70px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" DataSourceID="SQLDS_SecurityType" DefaultInsertValue="Group" DropDownControlType="DropDownList" ListTextField="LevelCode" ListValueField="LevelCode"/> <telerik:GridDropDownColumn DataField="DefaultDBID" UniqueName="DefaultDBID" HeaderText="Default DBID" HeaderStyle-Width="90px" SortExpression="DefaultDBID" FilterControlWidth="70px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" DefaultInsertValue="IPSMAIN" DataSourceID="SQLDS_ArgusDBID" DropDownControlType="DropDownList" ListTextField="ArgusDBID" ListValueField="ArgusDBID" /> <telerik:GridBoundColumn DataField="CompanyCode" UniqueName="CompanyCode" HeaderText="Company" HeaderStyle-Width="80px" SortExpression="CompanyCode" FilterControlWidth="60px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" ReadOnly="true"/> <telerik:GridBoundColumn DataField="EmployeeStatus" UniqueName="EmployeeStatus" HeaderText="Employee Status" HeaderStyle-Width="110px" SortExpression="EmployeeStatus" FilterControlWidth="90px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" ReadOnly="true"/> <telerik:GridBoundColumn DataField="CreatedBy" UniqueName="CreatedBy" HeaderText="Created By" HeaderStyle-Width="160px" SortExpression="CreatedBy" FilterControlWidth="140px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" Display="false" ReadOnly="true"/> <telerik:GridBoundColumn DataField="CreatedDate" UniqueName="CreatedDate" HeaderText="Created Date" HeaderStyle-Width="160px" SortExpression="CreatedDate" FilterControlWidth="140px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" Display="false" ReadOnly="true"/> <telerik:GridBoundColumn DataField="UpdatedBy" UniqueName="UpdatedBy" HeaderText="Updated By" HeaderStyle-Width="160px" SortExpression="UpdatedBy" FilterControlWidth="140px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" Display="false" ReadOnly="true"/> <telerik:GridBoundColumn DataField="UpdatedDate" UniqueName="UpdatedDate" HeaderText="Updated Date" HeaderStyle-Width="160px" SortExpression="UpdatedDate" FilterControlWidth="140px" FilterImageUrl="<%$ Resources:Images,FilterGray16%>" Display="false" ReadOnly="true"/> <telerik:GridBoundColumn DataField="ActiveFlag" UniqueName="ActiveFlag" Visible="false" /> </Columns> </MasterTableView> </telerik:RadGrid> </ContentTemplate> </asp:UpdatePanel></form></body></html>