How do I access RadNumericTextBox in footer template, from Server side?

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

    Posted 10 Jan 2014 Link to this post

    I have no clue why, but this code was working yesterday and today it doesn't.

    I have the following 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" />

    With the following javascript:
    <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
        <script type="text/javascript">
            var sumInput = null;
            var tempValue = 0;
            function Load(sender, args) {
                sumInput = sender;
            function Blur(sender, args) {
                sumInput.set_value(tempValue + sender.get_value());
            function Focus(sender, args) {           
                tempValue = sumInput.get_value() - sender.get_value();
            function CellValueChanged(sender, args) {
                var row = args.get_row();
                var rowIndex = row.rowIndex;
                var columnName = args.get_columnUniqueName();
                var cell = args.get_cell();
                var oldValue = args.get_cellValue();
                var newValue = '' + args.get_editorValue();
                var key = '' + row.cells[0].textContent
                var hc = document.getElementById('<%= ProductHash.ClientID%>');
                if (hc.value == '') {
                    if (newValue == "0") {
                    aProducts = new Array();
                    aProducts[key] = newValue;
                else {
                    var aProducts = JSON.parse(hc.value);
                    if (aProducts == null) {
                        if (newValue == "0") {
                        aProducts = new Array();
                        aProducts[key] = newValue;
                    else {
                        aProducts[key] = newValue;
                hc.value = JSON.stringify(aProducts);

    And the following server side code:
        Protected Sub btnProcess_Click(sender As Object, e As EventArgs)
                'Retrieve total quantity from footer
                Dim footer As GridFooterItem = DirectCast(RadGrid1.MasterTableView.GetItems(GridItemType.Footer)(0), GridFooterItem)
                Dim TotalQty As String = TryCast(footer.FindControl("TextBox2"), RadNumericTextBox).Text
 some stuff
            Catch ex As Exception
            End Try
        End Sub

    Yesterday, I was able to populate TotalQty with the value from the footer, but today, it is an empty string. The footer textbox shows a number in it. Server side, I am getting access to the footer textbox, but the Text property is an empty string.

    I have no clue why it stopped working.
  2. Steve
    Steve avatar
    84 posts
    Member since:
    Aug 2013

    Posted 10 Jan 2014 Link to this post

    Well, I found the problem.
    I had an open ticket with Telerik regarding trying to put the grid in and out of edit mode from the code behind without causing a javascript error. They recommended I do a RadGrid1.Rebind() after setting the EditMode.

    If bEditMode Then
        RadGrid1.MasterTableView.EditMode = Telerik.Web.UI.GridEditMode.Batch
        RadGrid1.MasterTableView.EditMode = Nothing
    End If

    Well, that apparently makes it so the textbox in the footer can't pass it's value back to the code behind.
    As soon as I comment out the Rebind, I gain access to the textbox in the footer.

    So, I'm back to square one again regarding putting the grid in and out of edit mode safely...
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top