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

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

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 10 Jan 2014, 11:37 PM
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%">
    <ClientSettings>
         <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" ></Scrolling>
            <ClientEvents OnBatchEditCellValueChanged="CellValueChanged" />
    </ClientSettings>
    <MasterTableView ShowFooter="true" AutoGenerateColumns="False"
        CurrentResetPageIndexAction="SetPageIndexToFirst" DataKeyNames="ID" DataSourceID="Products"
        Dir="LTR" Frame="Border" TableLayout="Auto" EditMode="Batch" BatchEditingSettings-OpenEditingEvent="Click" CommandItemDisplay="None">
        <Columns>
            <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">                               
                <ItemTemplate>
                    <%# Eval("Quantity")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadNumericTextBox ID="txtQuantity" runat="server" Width="40px" DataType="System.Int32"
                         NumberFormat-DecimalDigits="0" Skin="Forest">
                        <ClientEvents OnBlur="Blur" OnFocus="Focus" />
                    </telerik:RadNumericTextBox>
                </EditItemTemplate>
                <FooterTemplate>                   
                    <telerik:RadNumericTextBox ID="TextBox2" runat="server" Width="40px" DataType="System.Int32" NumberFormat-DecimalDigits="0" Skin="Forest" ReadOnly="True">
                        <ClientEvents OnLoad="Load" />
                    </telerik:RadNumericTextBox>
                </FooterTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
    <PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 10 Jan 2014, 11:39 PM
Never mind. I figured it out. It was the OnLoad in the ClientEvents of the textbox that was causing the problem.
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
Share this question
or