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

How to access a RadTextBox in a GridTableView TemplateColumn?

1 Answer 18 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 15 Feb 2019, 07:59 PM
<telerik:RadGrid ID="RadGrid1" runat="server" BorderColor="#0086B9" CssClass="radgrid1css" DataSourceID="SqlDataOrderInfo" Skin="Bootstrap" AutoGenerateColumns="False">
                 <GroupingSettings CollapseAllTooltip="Collapse all groups" />
                 <MasterTableView DataSourceID="SqlDataOrderInfo" DataKeyNames="SN,OrderNo">
                      
                     <DetailTables>
                         <telerik:GridTableView runat="server" DataKeyNames="SN" DataSourceID="SqlDataOrderItems"
                              AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True">
                             <ParentTableRelation>
                                 <telerik:GridRelationFields DetailKeyField="OrderNo" MasterKeyField="OrderNo" />
                             </ParentTableRelation>
                             <CommandItemSettings ShowAddNewRecordButton="False" ShowRefreshButton="False" />
                             <Columns>
                                 <telerik:GridBoundColumn DataField="ItemName" FilterControlAltText="Filter ItemName column" HeaderText="Item Name" UniqueName="ItemName">
                                 </telerik:GridBoundColumn>
                                 <telerik:GridBoundColumn DataField="ItemDescription" FilterControlAltText="Filter ItemDescription column" HeaderText="Item Description" UniqueName="ItemDescription">
                                 </telerik:GridBoundColumn>
                                 <telerik:GridCheckBoxColumn DataField="Status" DataType="System.Boolean"
                                    FilterControlAltText="Filter Status column" HeaderText="Status" UniqueName="Status">
                                     <HeaderStyle HorizontalAlign="Center" />
                                     <ItemStyle HorizontalAlign="Center" />
                                 </telerik:GridCheckBoxColumn>
                                 <telerik:GridTemplateColumn DataField="Comment" FilterControlAltText="Filter Comment column"
                                    HeaderText="Comment" UniqueName="Comment">
                                     <ItemTemplate>
                                         <telerik:RadTextBox ID="RadTextBox1" Runat="server" Skin="Bootstrap" TextMode="MultiLine"
                                              Width="100%" LabelWidth="40%" Resize="None" Text='<%# eval("Comment") %>'>
                                         </telerik:RadTextBox>
                                     </ItemTemplate>
                                 </telerik:GridTemplateColumn>
                             </Columns>
                         </telerik:GridTableView>
                     </DetailTables>
                      
                     <CommandItemSettings ShowAddNewRecordButton="False" ShowRefreshButton="False" />
                     <Columns>
                         <telerik:GridBoundColumn DataField="OrderId" DataType="System.Int32" FilterControlAltText="Filter
                          OrderId column" HeaderText="OrderId" SortExpression="OrderId" UniqueName="OrderId">
                         </telerik:GridBoundColumn>
                         <telerik:GridBoundColumn DataField="OrderNo" DataType="System.Int32" FilterControlAltText="Filter
                            OrderNo column" HeaderText="OrderNo" SortExpression="OrderNo" UniqueName="OrderNo">
                         </telerik:GridBoundColumn>
                         <telerik:GridBoundColumn DataField="Price" FilterControlAltText="Filter Price column" HeaderText="Price" SortExpression="Price" UniqueName="Price">
                         </telerik:GridBoundColumn>
                         <telerik:GridBoundColumn DataField="Item" FilterControlAltText="Filter Item column" HeaderText="Item" SortExpression="Item" UniqueName="Item">
                         </telerik:GridBoundColumn>
                         <telerik:GridBoundColumn DataField="SupplierName" FilterControlAltText="Filter SupplierName column" HeaderText="SupplierName" SortExpression="SupplierName" UniqueName="SupplierName">
                         </telerik:GridBoundColumn>
                     </Columns>
                     <HeaderStyle BackColor="#E8F0F9" BorderColor="#0086B9" ForeColor="#0086B9" />
                     <CommandItemStyle BackColor="#0086B9" ForeColor="White" Height="35px" HorizontalAlign="Center" />
                 </MasterTableView>
             </telerik:RadGrid>

 

Code Behind

Protected Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
 
 
        For Each item As GridDataItem In RadGrid1.MasterTableView.Items
 
            Dim lbtn As RadTextBox = DirectCast(item("Comment").FindControl("RadTextBox1"), RadTextBox)
 
            Dim custoID As Single = item.GetDataKeyValue("SN")
 
            
            DrugSQL("update orderitem set comment='" & lbtn.Text & "'  where sn='" & custoID & "'  ")
        Next
 
    End Sub

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 20 Feb 2019, 09:10 AM
Hello John,

The RadTextBox is placed inside the GridTableView and you can access it by traversing the grid tables recursively. 

To do that, you can use the steps and approach demonstrated in the following article:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/hierarchy/hiding-the-expand-collapse-images-when-no-records

You can also check Batch editing mode which is supported with hierarchy:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or