Access a control of Grid edit item template

6 posts, 0 answers
  1. Ignatiuz
    Ignatiuz avatar
    7 posts
    Member since:
    May 2010

    Posted 14 Sep 2011 Link to this post

    Hi,
    How can i access a control of edit itemtemplate of telerik grid in ItemCommand Event?

    My code:-
    if

    (e.CommandName == "GetPrice")  

    {

        if (e.Item is GridEditableItem)  

        {

        GridEditableItem editItem = (GridEditableItem)e.Item;

        TextBox box = (TextBox)editItem["SharePrice"].FindControl("txtPrice");
        }

    }

    the "box" gets null value here.
    I am not able to access the text box "txtPrice" of column "SharePrice".
  2. Elliott
    Elliott avatar
    391 posts
    Member since:
    May 2010

    Posted 14 Sep 2011 Link to this post

    please attach code and (especially) HTML
    the CommandName is Update or PerformInsert

    <Columns>
        <telerik:GridButtonColumn UniqueName="EditColumn" Text="Edit" CommandName="Edit" /> 
        <telerik:GridBoundColumn UniqueName="SpiffID" DataField="SpiffID" HeaderText="SpiffID" ReadOnly="True" />
        <telerik:GridBoundColumn UniqueName="Seq" DataField="Seq" HeaderText="seq" />               
        <telerik:GridTemplateColumn UniqueName="CashBack" HeaderText="CashBack" >
            <ItemTemplate>
                <asp:Label ID="lblCashBack" Text='<%# Bind("CashBack") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbCashBack" text='<%# Eval("CashBack") %>' runat="server">
                    <NumberFormat DecimalDigits="2" />
                </telerik:RadNumericTextBox>
                <asp:RequiredFieldValidator ID="rfvCashBack" ControlToValidate="rntbCashBack" ErrorMessage="Required" runat="server" />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridBoundColumn UniqueName="CaseDollarItem" DataField="CaseDollarItem" HeaderText="CaseDollarItem" />
        <telerik:GridCheckBoxColumn UniqueName="AllorByItem" DataField="AllOrByItem" HeaderText="AllItems" />
        <telerik:GridTemplateColumn UniqueName="QtytoOrder" HeaderText="Qty to Order">
            <ItemTemplate>
                <asp:Label ID="lblQtytoOrder" Text='<%# Bind("QtytoOrder") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbQtytoOrder" Text='<%# Eval("QtytoOrder") %>' runat="server" >
                    <NumberFormat DecimalDigits="0" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="DollartoOrder" HeaderText="$ to Order">
            <ItemTemplate>
                <asp:Label ID="lblDollartoOrder" Text='<%# Eval("DollartoOrder") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbDollartoOrder" runat="server" >
                    <NumberFormat DecimalDigits="2" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="MinQty" HeaderText="Min Qty">
            <ItemTemplate>
                <asp:Label ID="lblMinQty" Text='<%# Eval("MinQty") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbMinQty" runat="server" >
                    <NumberFormat DecimalDigits="0" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="MinDollar" HeaderText="Min Dollar">
            <ItemTemplate>
                <asp:Label ID="lblMinDollar" Text='<%# Eval("MinDollar") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadNumericTextBox ID="rntbMinDollar" runat="server" >
                    <NumberFormat DecimalDigits="2" />
                </telerik:RadNumericTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn UniqueName="SpiffDescription" >
            <ItemTemplate>
                <asp:Label ID="lblSpiffDescription" Text='<%# Eval("SpiffDescription") %>' runat="server" />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadTextBox ID="rtbSpiffDescription" Text='<%# Eval("SpiffDescription") %>' Width="500px" runat="server">
                </telerik:RadTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" Text="Delete" />
    </Columns>
    works with
    Protected Sub rgSpiffDetail_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgSpiffDetail.ItemCommand
        Dim TableName, CommandName As String
        Dim gcItem As GridCommandItem = Nothing
        Dim gefiItem As GridEditFormInsertItem = Nothing
        Dim geItem As GridEditableItem = Nothing
        Dim gdItem As GridDataItem = Nothing
        Dim gefItem As GridEditFormItem = Nothing
        Dim gdSpiff, gdVendor As GridDataItem
        Dim SpiffID, ItemID As Integer
        Dim rlbItems As RadListBox = Nothing
        Dim ws As CommonFunctions = Nothing
     
        CommandName = e.CommandName
        Select Case CommandName
            Case "InitInsert"
                gcItem = DirectCast(e.Item, GridCommandItem)
                TableName = gcItem.OwnerTableView.Name
                If TableName = "Items" Then
                    gdSpiff = e.Item.OwnerTableView.ParentItem
                    gdVendor = gdSpiff.OwnerTableView.ParentItem
                    VendorID = gdVendor.OwnerTableView.DataKeyValues(gdVendor.ItemIndex)("VendorID")
                End If
            Case "PerformInsert"
                If TypeOf e.Item Is GridEditFormInsertItem Then
                    gefiItem = DirectCast(e.Item, GridEditFormInsertItem)
                    TableName = gefiItem.OwnerTableView.Name
                    If TableName = "Spiffs" Then
                        InsertSpiff(gefiItem)
                    ElseIf TableName = "Items" Then
                        gdSpiff = e.Item.OwnerTableView.ParentItem
                        SpiffID = gdSpiff.OwnerTableView.DataKeyValues(gdSpiff.ItemIndex)("SpiffID")
                        geItem = DirectCast(e.Item, GridEditableItem)
                        rlbItems = CType(geItem.Cells(1).FindControl("rlbItems"), RadListBox)
                        If rlbItems.SelectedItems.Count > 1 Then
                            ApplyMultipleSelections(SpiffID, rlbItems)
                        Else
                            ItemID = rlbItems.SelectedValue
                            ws = New CommonFunctions
                            ws.ApplyItemtoSpiff(SpiffID, ItemID)
                        End If
                    End If
                End If
            Case "Delete"
                gdItem = DirectCast(e.Item, GridDataItem)
                TableName = gdItem.OwnerTableView.Name
                If TableName = "Items" Then
                    ItemID = CInt(gdItem.OwnerTableView.DataKeyValues(gdItem.ItemIndex)("ItemID"))
                    SpiffID = CInt(gdItem.OwnerTableView.DataKeyValues(gdItem.ItemIndex)("SpiffID"))
                    ws = New CommonFunctions
                    ws.DecoupleItemFromSpiff(ItemID, SpiffID)
                ElseIf TableName = "Spiffs" Then
                    SpiffID = CInt(gdItem.OwnerTableView.DataKeyValues(gdItem.ItemIndex)("SpiffID"))
                    ws = New CommonFunctions
                    ws.DeleteSpiffDetail(SpiffID)
                End If
            Case "Update"
                If TypeOf e.Item Is GridEditFormItem Then
                    gefItem = DirectCast(e.Item, GridEditFormItem)
                    TableName = gefItem.OwnerTableView.Name
                    If TableName = "Spiffs" Then
                        UpdateSpiff(gefItem)
                    End If
                End If
        End Select
    End Sub
    Private Sub InsertSpiff(ByVal gefiItem As GridEditFormInsertItem)
        Dim txtSeq, txtCaseDollarItem As TextBox
        Dim rntbCashBack, rntbQtytoOrder, rntbDollartoOrder, _
            rntbMinQty, rntbMinDollar As RadNumericTextBox
        Dim chkAllorByItem As CheckBox = Nothing
        Dim tcSpiffDescription As TableCell = Nothing
        Dim rtbSpiffDescription As RadTextBox = Nothing
        Dim Seq, QtytoOrder, MinQty, VendorID, SpiffID As Integer
        Dim CashBack, DollartoOrder, MinDollar As Double
        Dim CaseDollarItem, AllorByItem As Char
        Dim SpiffDescription As String = String.Empty
        Dim gdVendor As GridDataItem
        Dim ws As CommonFunctions = Nothing
     
        gdVendor = gefiItem.OwnerTableView.ParentItem
        VendorID = gdVendor.OwnerTableView.DataKeyValues(gdVendor.ItemIndex)("VendorID")
        txtSeq = DirectCast(gefiItem("Seq").Controls(0), TextBox)
        rntbCashBack = DirectCast(gefiItem("CashBack").Controls(1), RadNumericTextBox)
        txtCaseDollarItem = DirectCast(gefiItem("CaseDollarItem").Controls(0), TextBox)
        chkAllorByItem = DirectCast(gefiItem("AllorByItem").Controls(0), CheckBox)
        rntbQtytoOrder = DirectCast(gefiItem("QtytoOrder").Controls(1), RadNumericTextBox)
        rntbDollartoOrder = DirectCast(gefiItem("DollartoOrder").Controls(1), RadNumericTextBox)
        rntbMinQty = DirectCast(gefiItem("MinQty").Controls(1), RadNumericTextBox)
        rntbMinDollar = DirectCast(gefiItem("MinDollar").Controls(1), RadNumericTextBox)
        tcSpiffDescription = gefiItem.Cells(1)
        rtbSpiffDescription = DirectCast(tcSpiffDescription.FindControl("rtbSpiffDescription"), RadTextBox)
        If txtCaseDollarItem.Text = "I" _
        Or txtCaseDollarItem.Text = "C" _
        Or txtCaseDollarItem.Text = "D" Then
        Else
            Exit Sub
        End If
        If txtSeq.Text.Trim = String.Empty Then
            Seq = 0
        Else
            Seq = CInt(txtSeq.Text)
        End If
        CashBack = rntbCashBack.Value
        CaseDollarItem = CType(txtCaseDollarItem.Text, Char)
        AllorByItem = IIf(chkAllorByItem.Checked, "A", "I")
        QtytoOrder = CInt(NullableValue(rntbQtytoOrder))
        DollartoOrder = NullableValue(rntbDollartoOrder)
        MinQty = CInt(NullableValue(rntbMinQty))
        MinDollar = NullableValue(rntbMinDollar)
        SpiffDescription = rtbSpiffDescription.Text
        ws = New CommonFunctions
        SpiffID = ws.InsertSpiffDetail(VendorID, Seq, SpiffDescription, _
            CashBack, AllorByItem, CaseDollarItem, QtytoOrder, DollartoOrder, _
            MinQty, MinDollar)
    End Sub
    Private Sub UpdateSpiff(ByVal gefItem As GridEditFormItem)
        Dim txtSeq, txtCaseDollarItem As TextBox
        Dim rntbCashBack, rntbQtytoOrder, rntbDollartoOrder, _
            rntbMinQty, rntbMinDollar As RadNumericTextBox
        Dim tcSpiffDescription As TableCell = Nothing
        Dim rtbSpiffDescription As RadTextBox = Nothing
        Dim chkAllorByItem As CheckBox = Nothing
        Dim Seq, QtytoOrder, MinQty, SpiffID As Integer
        Dim CashBack, DollartoOrder, MinDollar As Double
        Dim CaseDollarItem, AllorByItem As Char
        Dim SpiffDescription As String = String.Empty
        Dim ws As CommonFunctions = Nothing
     
        txtSeq = DirectCast(gefItem("Seq").Controls(0), TextBox)
        rntbCashBack = DirectCast(gefItem("CashBack").Controls(1), RadNumericTextBox)
        txtCaseDollarItem = DirectCast(gefItem("CaseDollarItem").Controls(0), TextBox)
        chkAllorByItem = DirectCast(gefItem("AllorByItem").Controls(0), CheckBox)
        rntbQtytoOrder = DirectCast(gefItem("QtytoOrder").Controls(1), RadNumericTextBox)
        rntbDollartoOrder = DirectCast(gefItem("DollartoOrder").Controls(1), RadNumericTextBox)
        rntbMinQty = DirectCast(gefItem("MinQty").Controls(1), RadNumericTextBox)
        rntbMinDollar = DirectCast(gefItem("MinDollar").Controls(1), RadNumericTextBox)
        tcSpiffDescription = gefItem.Cells(1)
        rtbSpiffDescription = DirectCast(tcSpiffDescription.FindControl("rtbSpiffDescription"), RadTextBox)
     
        SpiffID = CInt(gefItem.OwnerTableView.DataKeyValues(gefItem.ItemIndex)("SpiffID"))
        If txtSeq.Text.Trim = String.Empty Then
            Seq = 0
        Else
            Seq = CInt(txtSeq.Text)
        End If
        CashBack = rntbCashBack.Value
        CaseDollarItem = CType(txtCaseDollarItem.Text, Char)
        AllorByItem = IIf(chkAllorByItem.Checked, "A", "I")
        QtytoOrder = CInt(NullableValue(rntbQtytoOrder))
        DollartoOrder = NullableValue(rntbDollartoOrder)
        MinQty = CInt(NullableValue(rntbMinQty))
        MinDollar = NullableValue(rntbMinDollar)
        SpiffDescription = rtbSpiffDescription.Text
        ws = New CommonFunctions
        ws.UpdateSpiffDetail(SpiffID, Seq, SpiffDescription, CashBack, _
        AllorByItem, CaseDollarItem, QtytoOrder, DollartoOrder, _
        MinQty, MinDollar)
    End Sub

    I explicitly tease out the control from the table cell, and use a different object for Inserts and Updates
    hope this helps


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Sep 2011 Link to this post

    Hello Deepesh,

    I am not quite sure about the requirement. Please make sure that the GetPrice method is called after the Editform is rendered.
    Take a look into the following thread which discussed similar scenario.
    find control on item command in Radgrid.

    Thanks,
    Shinu.
  5. Vishu
    Vishu avatar
    18 posts
    Member since:
    May 2014

    Posted 09 Jul 2015 Link to this post

    Hi ,
    I am having the same issue. With batch editing, would like to calculate and update the radtextbox in one column based on text changed event of another radtextbox. While doing this not able to access the to be updated radtextbox on text changed event.

    I had used two approaches as listed in cs file but in bot cases its not detecting the second radtextbox.

    I am Using 2015 Q2 dlls.

    ​ASPX:

    <telerik:RadGrid ID="GridItems" runat="server" AllowAutomaticInserts="false" AllowAutomaticUpdates="false" AllowAutomaticDeletes="false" pageSize="20" Skin="Office2007" EnableEmbeddedSkins="true"
                              AutoGenerateColumns="false" CellSpacing="0" AllowPaging="true" AllowCustomPaging="true"  AllowSorting="true" ShowGroupPanel="false" OnItemDataBound="GridItems_ItemDataBound"
                         AllowMultiRowSelection="false" AllowMultiRowEdit="false" MasterTableView-PagerStyle-AlwaysVisible="false" OnNeedDataSource="GridItems_NeedDataSource" OnItemCommand="GridItems_ItemCommand" 
                         OnSortCommand ="GridItems_SortCommand" OnUpdateCommand="GridItems_UpdateCommand" OnEditCommand="GridItems_EditCommand" OnItemCreated="GridItems_ItemCreated" AllowFilteringByColumn="true" >
           
                    <ClientSettings AllowColumnsReorder="false" AllowDragToGroup="false" EnableRowHoverStyle="true" AllowKeyboardNavigation="true">             
                        <Scrolling AllowScroll="false" UseStaticHeaders="true" SaveScrollPosition="true" ScrollHeight="500px" ></Scrolling>            
                        <Selecting AllowRowSelect="true" />
                        <Resizing AllowColumnResize="True" ResizeGridOnColumnResize="true"
                                        ClipCellContentOnResize="true" EnableRealTimeResize="false" AllowResizeToFit="true" />   
                        <ClientEvents OnFilterMenuShowing="filterMenuShowing" />                 
                    </ClientSettings> 
                    <FilterMenu OnClientShowing="MenuShowing" />
                        <GroupingSettings  CaseSensitive="false"/>
                    <PagerStyle Mode="NextPrevAndNumeric" Position="Bottom" ></PagerStyle>
                        
                    <MasterTableView DataKeyNames="CountEventId,BusinessUnit,StorageArea,ItemNumber" ClientDataKeyNames="CountEventId,BusinessUnit,StorageArea,ItemNumber"  CommandItemDisplay="Top" TableLayout="Fixed" Width="100%" EditMode="Batch" BatchEditingSettings-EditType="Cell" >                    
                        <CommandItemTemplate>
                            <table style="width: 100%">
                                <tr>
                                        <td>
                                                    </td>
                                         <td >
                                        <table style="float: right; vertical-align: top; padding-right: 10px">
                                                <tr>
                                                    <td>
                                                        <asp:Button ID="btnSaveCount" runat="server" Text="Save Count Data" TextAlign="Right" AutoPostBack="true" OnClick="btnSaveCount_Click"/>
                                                    </td>
                                                </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </CommandItemTemplate>
                        <ItemStyle Wrap="true" />
                        <HeaderStyle Wrap="true" />                    
                        <Columns>
                             <telerik:GridTemplateColumn HeaderText="#" UniqueName="RowNumber" Visible="false">
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="lblRowNumber" Width="50px" Text='<%# Container.DataSetIndex+1 %>'></asp:Label>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Select" UniqueName="Rep01" AllowFiltering="false" HeaderStyle-Width="50px">
                                     <HeaderTemplate>
                                         <asp:CheckBox runat="server" value="check" id="checkbox"  onclick="CheckAll(this);"  />
                                     </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:CheckBox runat="server" AutoPostBack="false" Width="5%" ID="checkbox2" />
                                    </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="CountEventId"  UniqueName="CountEventId"  Display="false" />                    
                            <telerik:GridBoundColumn DataField="BusinessUnit"  UniqueName="BusinessUnit" DataType="System.String"  HeaderText="IBU" SortExpression="BusinessUnit" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" FilterControlWidth="52px" ReadOnly="true" HeaderStyle-Width="95px"/>                    
                            <telerik:GridBoundColumn DataField="StorageArea"  UniqueName="StorageArea"  DataType="System.String" HeaderText="Area" SortExpression="StorageArea" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" FilterControlWidth="52px" ReadOnly="true" HeaderStyle-Width="95px"/>                                        
                            <telerik:GridBoundColumn DataField="level1"  UniqueName="level1"  DataType="System.String" HeaderText="Level 1" SortExpression="level1" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" FilterControlWidth="52px" ReadOnly="true" HeaderStyle-Width="95px" />                                        
                            <telerik:GridBoundColumn DataField="level2"  UniqueName="level2"  DataType="System.String" HeaderText="Level 2" SortExpression="level2" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" FilterControlWidth="52px" ReadOnly="true" HeaderStyle-Width="95px" />                                        
                            <telerik:GridBoundColumn DataField="level3"  UniqueName="level3"  DataType="System.String" HeaderText="Level 3" SortExpression="level3" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" FilterControlWidth="52px" ReadOnly="true" HeaderStyle-Width="95px" />                                        
                            <telerik:GridBoundColumn DataField="level4" Display="false"  DataType="System.String" UniqueName="level4"  HeaderText="Level 4" SortExpression="level4" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" FilterControlWidth="52px" ReadOnly="true"  />                                        
                            <telerik:GridBoundColumn DataField="ItemNumber" UniqueName="ItemNumber" DataType="System.String" HeaderText="Item ID" SortExpression="ItemNumber"  ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" FilterControlWidth="50px" ReadOnly="true"  HeaderStyle-Width="95px"  />                                        
                            <telerik:GridBoundColumn DataField="ItemDescription" UniqueName="description" HeaderText="Description" SortExpression="ItemDescription" AllowFiltering="false"  ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" ReadOnly="true" HeaderStyle-Width="80px" />                  
                            <telerik:GridBoundColumn DataField="UnitOfMeasure" UniqueName="uom" HeaderText="UOM" SortExpression="UnitOfMeasure" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" ReadOnly="true" HeaderStyle-Width="70px"/>                                                                             
                            <telerik:GridBoundColumn DataField="OEMPartNo" UniqueName="oempartnumber" HeaderText="OEM</br>Part #" SortExpression="OEMPartNo" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" ReadOnly="true" HeaderStyle-Width="60px"/>                                                                             
                            <telerik:GridBoundColumn DataField="OEM" UniqueName="oemname" HeaderText="OEM" SortExpression="OEM" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" ReadOnly="true"  HeaderStyle-Width="60px" />                                                                             
                            <telerik:GridBoundColumn DataField="LastCountedBy" UniqueName="LastCountedBy" HeaderText="Last Count</br>By" SortExpression="LastCountedBy" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" ReadOnly="true" HeaderStyle-Width="70px"/>                                                                             
                            <telerik:GridDateTimeColumn DataField="startCountDate" AllowFiltering="false" UniqueName="startCountDate"  DataFormatString="{0:MM/dd/yyyy}" DataType="System.DateTime" HeaderText="Last Count</br>Date" SortExpression="startCountDate" HeaderStyle-Width="70px"
                                 HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"  ItemStyle-VerticalAlign ="Middle" ReadOnly="true"></telerik:GridDateTimeColumn>   
                            <telerik:GridDateTimeColumn DataField="LastCountDate" AllowFiltering="false" UniqueName="lastCountDate" DataFormatString="{0:MM/dd/yyyy}" DataType="System.DateTime" HeaderText="Start Count</br>Date" 
                                SortExpression="LastCountDate" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"  ItemStyle-VerticalAlign ="Middle" ReadOnly="true" HeaderStyle-Width="70px"></telerik:GridDateTimeColumn>                                                   
                            <telerik:GridTemplateColumn UniqueName="countqty" HeaderText="Count<br>Qty" SortExpression="countqty" AllowFiltering="false"  ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" HeaderStyle-Width="50px">                                                   
                              <EditItemTemplate>
                                  <telerik:RadTextBox ID="txtboxqty" runat="server" Text='<%# Convert.ToInt64(Eval("countqty")) > 0 ? Eval("countqty") : "" %>' AutoPostBack="true" OnTextChanged="txtboxqty_TextChanged" onkeypress="return isValidNumber(event)" MaxLength="9" Width="50px">
                                  </telerik:RadTextBox>
                              </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="AllocatedQty" AllowFiltering="false" UniqueName="AllocatedQty" DataType="System.Decimal" HeaderText="WIN </br> Allocated" SortExpression="AllocatedQty"  HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign ="Middle" ReadOnly="true"  HeaderStyle-Width="60px"/>                                                                          
                            <telerik:GridBoundColumn DataField="totalcount" UniqueName="totalcount" HeaderText="Total </br> Count" SortExpression="totalcount" AllowFiltering="false"  ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" ReadOnly="true" HeaderStyle-Width="70px"/>                                                                             
                            <telerik:GridBoundColumn DataField="QtyOnHand" UniqueName="QtyOnHand" HeaderText="PS </br> on Hand" SortExpression="QtyOnHand" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" ReadOnly="true" HeaderStyle-Width="70px"/>                                                                             
                            <telerik:GridBoundColumn DataField="OnOrder" UniqueName="OnOrder" HeaderText="On Order Qty" SortExpression="OnOrder" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle" ReadOnly="true" HeaderStyle-Width="70px"/>                                                                                                    
                            <telerik:GridTemplateColumn DataField="discrepancy"  UniqueName="Discrepancy" HeaderText="Discrepancy" SortExpression="Discrepancy" AllowFiltering="false" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign ="Middle"  HeaderStyle-Width="90px">                         
                              <EditItemTemplate>
                                  <telerik:RadTextBox ID="txtboxdisp" Text= '<%# Convert.ToInt64(Eval("discrepancy")) > 0 ? Eval("discrepancy") : "" %>' runat="server" onkeypress="return isValidNumber(event)" MaxLength="9" Width="90px">
                                  </telerik:RadTextBox>
                              </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridNumericColumn
                                DataField="AverageCost" AllowFiltering="false" NumericType="Currency" UniqueName="AverageCost" DataType="System.Decimal" HeaderText="Avg. Cost" SortExpression="AverageCost"    HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign ="Middle" ReadOnly="true" HeaderStyle-Width="80px">
                            </telerik:GridNumericColumn>                         
                        </Columns>           
                         <NoRecordsTemplate>
                            <div>
                                No Records To Display
                            </div>
                        </NoRecordsTemplate>                             
                    </MasterTableView>        
                </telerik:RadGrid>

    AXPX.CS:

    protected void txtboxqty_TextChanged(object sender, EventArgs e)
            {
                RadTextBox txtqtycount = sender as RadTextBox;
                
                //Approach 1
                foreach (GridEditableItem item in GridItems.EditItems)
                {
                    RadTextBox txtAmount = item.FindControl("txtboxdisp") as RadTextBox;
                    txtAmount.Text = "ABCTEst";
                }

                //Approach 2
                foreach (GridItem grditem in GridItems.MasterTableView.Items)
                {
                    
                    if (grditem.Selected)
                    {
                        RadTextBox txtAmount = grditem.FindControl("txtboxdisp") as RadTextBox;
                        //txtAmount.Text = "TEST";
                        int totCount = !string.IsNullOrEmpty(grditem.Cells[16].Text) ? Convert.ToInt16(grditem.Cells[16].Text) : 0;
                    }
                }
                
            }  

  6. Vishu
    Vishu avatar
    18 posts
    Member since:
    May 2014

    Posted 12 Jul 2015 in reply to Vishu Link to this post

    Could someone please see if this is the issue with telerik?
  7. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 14 Jul 2015 Link to this post

    Hello Vishu,

    With Batch Editing there will be no editors in the items, because with that edit mode, only one editor is generated for the entire column and that editor is moved along the edited cells. Furthermore, since this is a client-side oriented editing, if you have an editor that will initiate a postback, all the changes in the grid will be lost, so if you need to perform some operations on the other cells you will have to use the BatchEditingManager.

    Detailed information on the available methods of BatchEditingManager could be found in the following help article:
    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017