How can I populate a RadNumericTextBox in footer from Code Behind?

2 posts, 0 answers
  1. Steve
    Steve avatar
    84 posts
    Member since:
    Aug 2013

    Posted 10 Jan 2014 Link to this post

    I have a RadNumericTextbox in the footer of a grid that I use for displaying a running total on a column when in edit mode.
    I populate the grid depending upon what the user selects for input. When in edit mode, and they update the quantity column,
    the textbox in the footer automatically totals that column.

    When I display non-editable data in the grid, I need to be able to manually update the total from the code behind. How can I
    gain access to the textbox and set it's value to be displayed?

    I tried the following code but it doesn't work. I can access the textbox and set the text property, but it doesn't display.

    I have tried this:
         Dim footer As GridFooterItem = DirectCast(RadGrid1.MasterTableView.GetItems(GridItemType.Footer)(0), GridFooterItem)
         Dim TotalQty As RadNumericTextBox = TryCast(footer.FindControl("TextBox2"), RadNumericTextBox)
         TotalQty.Text = dr("TotalQuantity")
    And, I have tried this:
         Dim TotalQty As RadNumericTextBox = FindControlRecursive(Page, "TextBox2")
         TotalQty.Text = dr("TotalQuantity")

    This is the grid:
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" DataSourceID="Products"
        Skin="Forest" GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound" Width="50%">
             <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" ></Scrolling>
                <ClientEvents OnBatchEditCellValueChanged="CellValueChanged" />
        <MasterTableView ShowFooter="true" AutoGenerateColumns="False"
            CurrentResetPageIndexAction="SetPageIndexToFirst" DataKeyNames="ID" DataSourceID="Products"
            Dir="LTR" Frame="Border" TableLayout="Auto" EditMode="Batch" BatchEditingSettings-OpenEditingEvent="Click" CommandItemDisplay="None">
                <telerik:GridBoundColumn DataField="ID" DataType="System.Int32"  ReadOnly="True" UniqueName="ID" />
                <telerik:GridBoundColumn DataField="ProductName" ReadOnly="true" HeaderText="Product" UniqueName="ProductName" />
                <telerik:GridTemplateColumn DataField="Quantity" UniqueName="Quantity" HeaderText="Quantity" DataType="System.Int32">                               
                        <%# Eval("Quantity")%>
                        <telerik:RadNumericTextBox ID="txtQuantity" runat="server" Width="40px" DataType="System.Int32"
                             NumberFormat-DecimalDigits="0" Skin="Forest">
                            <ClientEvents OnBlur="Blur" OnFocus="Focus" />
                        <telerik:RadNumericTextBox ID="TextBox2" runat="server" Width="40px" DataType="System.Int32" NumberFormat-DecimalDigits="0" Skin="Forest" ReadOnly="True">
                            <ClientEvents OnLoad="Load" />
        <PagerStyle Mode="NextPrevAndNumeric" />
  2. Steve
    Steve avatar
    84 posts
    Member since:
    Aug 2013

    Posted 10 Jan 2014 Link to this post

    Never mind. I figured it out. It was the OnLoad in the ClientEvents of the textbox that was causing the problem.
Back to Top