This is a migrated thread and some comments may be shown as answers.

Custom control in grid refresh page when used

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 20 Aug 2009, 01:27 PM
I have a rad grid with a custom control added in the grid whenever a row in the grid is expanded. This control has a radtabstrip control inside and for each radpageview, there are also controls. I have the update panels set in the right spot, at least i think i do. So when i go to use the checkbox or click one of the buttons in the control, the page refreshes and the custom control that was added in the grid is gone. I'm thinking maybe i have my update panels in the wrong spot or i need to do something so that the grid doesn't update when the controls are used. Any help or input on this would be greatly appreciated.

Here's my code for my grid....
<asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional" RenderMode="Inline"
            <ContentTemplate> 
                <table style="width: 100%;"
                    <tr valign="top"
                        <td valign="top" class="style28"
                            <table style="width: 820px"
                                <tr> 
                                    <td class="style25" valign="top"
                                        <asp:TextBox ID="TextBoxSearchLeft" runat="server" Font-Names="Calibri" Font-Size="Small"></asp:TextBox> 
                                        <asp:Label ID="LblHyphen" runat="server" Text="-" Font-Size="Larger"></asp:Label> 
                                        <asp:TextBox ID="TextBoxSearchRight" runat="server" Font-Names="Calibri" Font-Size="Small" 
                                            Visible="False"></asp:TextBox> 
                                        <cc1:MaskedEditExtender ID="TextBoxSearchLeft_MaskedEditExtender" runat="server" 
                                            Enabled="True" Mask="99/99/9999" MaskType="Date" OnFocusCssClass="MaskedEditFocus" 
                                            OnInvalidCssClass="MaskedEditError" TargetControlID="TextBoxSearchLeft"
                                        </cc1:MaskedEditExtender> 
                                        <cc1:CalendarExtender ID="TextBoxSearchLeft_CalendarExtender" runat="server" Enabled="True" 
                                            TargetControlID="TextBoxSearchLeft"
                                        </cc1:CalendarExtender> 
                                        <cc1:MaskedEditExtender ID="TextBoxSearchRight_MaskedEditExtender" runat="server" 
                                            Enabled="True" Mask="99/99/9999" MaskType="Date" OnFocusCssClass="MaskedEditFocus" 
                                            OnInvalidCssClass="MaskedEditError" TargetControlID="TextBoxSearchRight"
                                        </cc1:MaskedEditExtender> 
                                        <cc1:CalendarExtender ID="TextBoxSearchRight_CalendarExtender" runat="server" Enabled="True" 
                                            TargetControlID="TextBoxSearchRight"
                                        </cc1:CalendarExtender> 
                                    </td> 
                                    <td align="left" class="style26" valign="top"
                                        <asp:DropDownList ID="DDLCrit" runat="server" Height="20px" AutoPostBack="true"
                                            <asp:ListItem Value="0">Search Criteria</asp:ListItem> 
                                            <asp:ListItem Value="1">Facility Name</asp:ListItem> 
                                            <asp:ListItem Value="2">Hardware</asp:ListItem> 
                                            <asp:ListItem Value="3">In-Service Date</asp:ListItem> 
                                        </asp:DropDownList> 
                                    </td> 
                                    <td align="right" class="style27"
                                        <asp:ImageButton ID="BtnSearchFacilities" runat="server" ImageUrl="~/EDRC/Images/Search.png" 
                                            Width="26px" /> 
                                    </td> 
                                </tr> 
                            </table> 
                            <table style="width: 821px"
                                <tr> 
                                    <td class="style29"
                                        <telerik:RadGrid ID="RadGrid_Search" runat="server" DataSourceID="DS_Facility_Hardware_Search" 
                                            GridLines="None" Width="815px" AllowPaging="True" Height="257px" Style="margin-right: 0px" 
                                            PageSize="8" Skin="Gray"
                                            <HeaderContextMenu EnableTheming="True"
                                                <CollapseAnimation Duration="200" Type="OutQuint" /> 
                                            </HeaderContextMenu> 
                                            <PagerStyle PageButtonCount="1" /> 
                                            <MasterTableView AutoGenerateColumns="False" DataSourceID="DS_Facility_Hardware_Search"
                                                <RowIndicatorColumn> 
                                                    <HeaderStyle Width="20px" /> 
                                                </RowIndicatorColumn> 
                                                <ExpandCollapseColumn> 
                                                    <HeaderStyle Width="20px" /> 
                                                </ExpandCollapseColumn> 
                                                <NestedViewTemplate> 
                                                    <asp:Panel ID="PanelNestedGrid" runat="server"
                                                    </asp:Panel> 
                                                </NestedViewTemplate> 
                                                <Columns> 
                                                    <telerik:GridTemplateColumn> 
                                                        <ItemTemplate> 
                                                            <asp:ImageButton ID="BtnDelete" runat="server" CommandName="Select" ImageUrl="~/EDRC/Images/Symbol-Delete-small.png"
                                                            </asp:ImageButton> 
                                                        </ItemTemplate> 
                                                    </telerik:GridTemplateColumn> 
                                                    <telerik:GridBoundColumn DataField="FacilityID" DataType="System.Int32" HeaderText="FacilityID" 
                                                        ReadOnly="True" SortExpression="FacilityID" UniqueName="FacilityID" Visible="false"
                                                    </telerik:GridBoundColumn> 
                                                    <telerik:GridBoundColumn DataField="SFFacilityID" DataType="System.Int32" HeaderText="SFFacilityID" 
                                                        SortExpression="SFFacilityID" UniqueName="SFFacilityID" Visible="false"
                                                    </telerik:GridBoundColumn> 
                                                    <telerik:GridBoundColumn DataField="FacilityName" HeaderText="FacilityName" SortExpression="FacilityName" 
                                                        UniqueName="FacilityName"
                                                    </telerik:GridBoundColumn> 
                                                    <telerik:GridBoundColumn DataField="Website" HeaderText="Website" SortExpression="Website" 
                                                        UniqueName="Website"
                                                    </telerik:GridBoundColumn> 
                                                </Columns> 
                                            </MasterTableView> 
                                            <FilterMenu EnableTheming="True"
                                                <CollapseAnimation Duration="200" Type="OutQuint" /> 
                                            </FilterMenu> 
                                            <ClientSettings EnableRowHoverStyle="true"
                                                <Selecting AllowRowSelect="True" /> 
                                            </ClientSettings> 
                                        </telerik:RadGrid> 
                            </table> 
                        </td> 
                    </tr> 
                </table> 
            </ContentTemplate> 
        </asp:UpdatePanel> 


Here's the code from my custom control...
 <telerik:RadTabStrip ID="RadTabStrip1" runat="server"  
        MultiPageID="RadMultiPage1" SelectedIndex="2" Skin="Default2006"
        <Tabs> 
            <telerik:RadTab runat="server" Text="Information"  
                PageViewID="PageView_FacInformation" Selected="True"
 
            </telerik:RadTab> 
            <telerik:RadTab runat="server" Text="Allocate Hardware" PageViewID="PageView_AllocateHardware"
            
            </telerik:RadTab> 
            <telerik:RadTab runat="server" Text="Retire/Return Assets"  
                PageViewID="PageView_RetireAssets" > 
 
            </telerik:RadTab> 
            <telerik:RadTab runat="server" Text="History" PageViewID="PageView_History"
            
            </telerik:RadTab> 
        </Tabs> 
    </telerik:RadTabStrip> 
        <asp:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="Conditional" > 
                    <ContentTemplate> 
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="2"
    <telerik:RadPageView ID="PageView_FacInformation" runat="server"
 
                        <asp:Panel ID="Panel_Main" runat="server" Height="230px"
                            <asp:Label ID="Label1" runat="server" Style="font-size: 14px; position: absolute; 
                                top: 35px; left: 10px;" Text="Address" Font-Underline="True" /> 
                            <asp:Label ID="Label2" runat="server" Style="font-size: 14px; position: absolute; 
                                top: 89px; left: 10px; height: 17px;" Text="Contact Information" Font-Underline="True" /> 
                            <asp:Label ID="Label3" runat="server" Style="font-size: 14px; position: absolute; 
                                top: 35px; left: 270px; height: 17px; width: 182px;" Text="ISP/Phone Company Information" 
                                Font-Underline="True" /> 
                            <asp:Label ID="Label4" runat="server" Style="font-size: 14px; position: absolute; 
                                top: 155px; left: 270px;" Text="Hardware" Font-Underline="True" /> 
                            <asp:Label ID="Label5" runat="server" Style="font-size: 14px; position: absolute; 
                                top: 35px; left: 590px; height: 17px; width: 60px;" Font-Underline="True" Text="Comments" /> 
                            <asp:Label ID="lblAddress" runat="server" Style="position: absolute; top: 49px; left: 10px;" 
                                Text="Label" /> 
                            <asp:Label ID="lbl_ISP_Phone_Info" runat="server" Style="position: absolute; top: 49px; 
                                left: 270px;" Text="Label" /> 
                            <asp:Label ID="lblComments" runat="server" Style="position: absolute; top: 49px; 
                                left: 590px;" Text="Label" /> 
                            <asp:Label ID="lblContactInfo" runat="server" Style="position: absolute; top: 105px; 
                                left: 10px;" Text="Label" /> 
                            <asp:Label ID="lblHardware" runat="server" Style="position: absolute; top: 170px; 
                                left: 270px;" Text="Label" /> 
                        </asp:Panel> 
 
    </telerik:RadPageView> 
    <telerik:RadPageView ID="PageView_AllocateHardware" runat="server"
 <%--   <asp:UpdatePanel ID="UpdatePanel_AllocateHardware" runat="server"
    <ContentTemplate>--%> 
     
 
    <table style="border-width: 1px; border-color: #808080; width: 100%; border-bottom-style: solid; 
                    font-size: 12px;"> 
                    <tr> 
                        <td class="style5" colspan="0" style="border-width: 1px; border-color: #808080; border-top-style: solid;" 
                            valign="top"
                            <asp:CheckBox ID="CheckBoxPC" runat="server" AutoPostBack="True" Text="PC" /> 
                        </td> 
                        <td class="style7" colspan="0" style="border-color: #808080; border-spacing: 0px;" 
                            valign="top"
                            <table style="width: 100%; font-size: 12px;"
                                <tr> 
                                    <td class="style32" valign="top"
                                        <asp:Label ID="Label15" runat="server" Text="Search by SerialNumber/Tag"></asp:Label> 
                                        <br /> 
                                        <asp:TextBox ID="TextBoxPC" runat="server" BackColor="LightGray" Enabled="False" 
                                            Font-Names="Calibri" Font-Size="9pt" ForeColor="Gray" Height="14px"></asp:TextBox> 
                                        <asp:ImageButton ID="BtnPCSearch" runat="server" Enabled="False" ImageAlign="Top" 
                                            ImageUrl="~/EDRC/Images/Search.png" /> 
                                    </td> 
                                    <td valign="top"
                                        <asp:Label ID="Label16" runat="server" Text="Select a PC"></asp:Label> 
                                        <br /> 
                                        <asp:ListBox ID="ListBoxPC" runat="server" BackColor="LightGray" Enabled="False" 
                                            Font-Names="Calibri" Font-Size="9pt" ForeColor="Gray" Width="300px" DataTextField="Asset Name" 
                                            DataValueField="Assid"></asp:ListBox> 
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td align="right" class="style32" valign="bottom"
                                        <asp:CheckBox ID="CheckBoxPCContract" runat="server" AutoPostBack="True" BackColor="#CCCCCC" 
                                            Enabled="False" ForeColor="Gray" Text="Contract" /> 
                                        &nbsp;&nbsp;&nbsp;&nbsp; 
                                    </td> 
                                    <td align="left" valign="top"
                                        <asp:Label ID="Label17" runat="server" Text="Expiration Date"></asp:Label> 
                                        <br /> 
                                        <asp:TextBox ID="TextBoxPCContractDate" runat="server" BackColor="LightGray" Enabled="False" 
                                            Font-Names="Calibri" Font-Size="9pt" ForeColor="Gray" Height="14px" Width="80px"></asp:TextBox> 
                                        <cc1:MaskedEditExtender ID="TextBoxPCContractDate_MaskedEditExtender" runat="server" 
                                            Enabled="True" Mask="99/99/9999" MaskType="Date" TargetControlID="TextBoxPCContractDate" 
                                            CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder="" CultureDateFormat="" 
                                            CultureDatePlaceholder="" CultureDecimalPlaceholder="" CultureThousandsPlaceholder="" 
                                            CultureTimePlaceholder=""
                                        </cc1:MaskedEditExtender> 
                                        <cc1:CalendarExtender ID="TextBoxPCContractDate_CalendarExtender" runat="server" 
                                            Enabled="True" TargetControlID="TextBoxPCContractDate"
                                        </cc1:CalendarExtender> 
                                        <cc1:MaskedEditValidator ID="MEV_TextBoxPCContractDate" runat="server" ControlExtender="TextBoxPCContractDate_MaskedEditExtender" 
                                            ControlToValidate="TextBoxPCContractDate" Display="Dynamic" EmptyValueBlurredText="*" 
                                            EmptyValueMessage="Date is required" InvalidValueBlurredMessage="*" InvalidValueMessage="Date is invalid" 
                                            TooltipMessage="Input a date" ValidationGroup="MKE" ErrorMessage="MEV_TextBoxPCContractDate" /> 
                                    </td> 
                                </tr> 
                            </table> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td class="style9" colspan="0" style="border-width: 1px; border-color: #808080;" 
                            valign="top"
                        </td> 
                    </tr> 
                    <tr> 
                        <td class="style4" style="border-width: 1px; border-color: #808080; border-top-style: solid" 
                            valign="top"
                            <asp:CheckBox ID="CheckBoxScanner" runat="server" AutoPostBack="True" Text="Scanner" /> 
                        </td> 
                        <td height="80" valign="top"
                            <table style="width: 100%; font-size: 12px;"
                                <tr> 
                                    <td class="style6" valign="top"
                                        <asp:Label ID="Label13" runat="server" Text="Search by SerialNumber/Tag"></asp:Label> 
                                        <br /> 
                                        <asp:TextBox ID="TextBoxScanner" runat="server" BackColor="LightGray" Enabled="False" 
                                            Font-Names="Calibri" Font-Size="9pt" ForeColor="Gray" Height="14px"></asp:TextBox> 
                                        <asp:ImageButton ID="BtnScannerSearch" runat="server" Enabled="False" ImageAlign="Top" 
                                            ImageUrl="~/EDRC/Images/Search.png" /> 
                                        <br /> 
                                    </td> 
                                    <td valign="top"
                                        <asp:Label ID="Label14" runat="server" Text="Select a Scanner"></asp:Label> 
                                        <br /> 
                                        <asp:ListBox ID="ListBoxScanner" runat="server" BackColor="LightGray" Enabled="False" 
                                            Font-Names="Calibri" Font-Size="9pt" ForeColor="Gray" Width="300px" DataTextField="SerialNumber" 
                                            DataValueField="Assid"></asp:ListBox> 
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td align="right" class="style6" valign="bottom"
                                        <asp:CheckBox ID="CheckBoxScannerContract" runat="server" AutoPostBack="True" Enabled="False" 
                                            ForeColor="Gray" Text="Contract" /> 
                                        &nbsp;&nbsp;&nbsp;&nbsp; 
                                    </td> 
                                    <td valign="top"
                                        <asp:Label ID="Label18" runat="server" Text="Expiration Date"></asp:Label> 
                                        <br /> 
                                        <asp:TextBox ID="TextBoxScannerContractDate" runat="server" BackColor="LightGray" 
                                            Enabled="False" Font-Names="Calibri" Font-Size="9pt" ForeColor="Gray" Height="14px" 
                                            Width="80px"></asp:TextBox> 
                                        <cc1:MaskedEditExtender ID="TextBoxScannerContractDate_MaskedEditExtender" runat="server" 
                                            Enabled="True" Mask="99/99/9999" MaskType="Date" TargetControlID="TextBoxScannerContractDate" 
                                            CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder="" CultureDateFormat="" 
                                            CultureDatePlaceholder="" CultureDecimalPlaceholder="" CultureThousandsPlaceholder="" 
                                            CultureTimePlaceholder=""
                                        </cc1:MaskedEditExtender> 
                                        <cc1:CalendarExtender ID="TextBoxScannerContractDate_CalendarExtender" runat="server" 
                                            Enabled="True" TargetControlID="TextBoxScannerContractDate"
                                        </cc1:CalendarExtender> 
                                        <cc1:MaskedEditValidator ID="MEV_TextBoxScannerContractDate" runat="server" ControlExtender="TextBoxScannerContractDate_MaskedEditExtender" 
                                            ControlToValidate="TextBoxScannerContractDate" Display="Dynamic" EmptyValueBlurredText="*" 
                                            EmptyValueMessage="Date is required" InvalidValueBlurredMessage="*" InvalidValueMessage="Date is invalid" 
                                            TooltipMessage="Input a date" ValidationGroup="MKE" ErrorMessage="MEV_TextBoxScannerContractDate" /> 
                                    </td> 
                                </tr> 
                            </table> 
                        </td> 
                    </tr> 
                </table> 
<%--                                    </ContentTemplate> 
    </asp:UpdatePanel>--%> 
                <table style="width: 100%; font-size: 12px;"
                    <tr> 
                        <td class="style30" valign="bottom"
                            <asp:Label ID="ErrorlblNewHardware" runat="server" ForeColor="Red" Text="Label" Visible="False"></asp:Label> 
<%--                            <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel_AllocateHardware 
                                DisplayAfter="0"
                                <ProgressTemplate> 
                                    <asp:Image ID="Image2" runat="server" ImageUrl="~/EDRC/Images/ajax-loader.gif" /> 
                                </ProgressTemplate> 
                            </asp:UpdateProgress>--%> 
                        </td> 
                        <td class="style31"
                            <asp:Label ID="lblHardwareID" runat="server" Text="lbl" Visible="False"></asp:Label> 
                        </td> 
                        <td> 
                            <asp:ImageButton ID="BtnSaveHardware" runat="server" ImageUrl="~/EDRC/Images/Save_small.png" /> 
                        </td> 
                    </tr> 
                </table> 
 
    </telerik:RadPageView> 
        <telerik:RadPageView ID="PageView_RetireAssets" runat="server"
    </telerik:RadPageView> 
        <telerik:RadPageView ID="PageView_History" runat="server"
    </telerik:RadPageView> 
    </telerik:RadMultiPage> 
                        </ContentTemplate> 
                </asp:UpdatePanel> 


1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 21 Aug 2009, 11:12 AM
Hi Ben,

The behavior you are getting happens most of the time when you add your custom user control to the controls collection of the page once on a button click or some other event. If this is the case, note that your controls are not recreated on every postback, but only when you, for example, click a button or expand an item.

I suggest you create your controls conditionally in Page_Init or Page_Load, so that it is recreated on every postback.

Kind regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or