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

FindControl in child DetailTable

1 Answer 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Martin
Top achievements
Rank 2
John Martin asked on 01 Aug 2008, 08:31 AM
Hi there

I am currently finding controls with the following method:

Dim

parentItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)

Me

.dsResellerDetails.SelectParameters.Add("mkOrderId", CType(parentItem.FindControl("lblID"), Label).Text)

However I need to get a text value from a gridview within a child DetailTable gridview?

i.e. I have expanded a record then expanded details within that expansion and need to FindControl at that level.

Many thanks

Steve

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Aug 2008, 10:10 AM
Hi Steve,

Set the Name property for the detail table and try accessing the control in the detail table in the ItemDataBound event as shown below.

ASPX:
<MasterTableView  CommandItemDisplay="Top"    TableLayout="fixed"   Name="Master" DataSourceID="SqlDataSource1" > 
                
     <DetailTables> 
         <telerik:GridTableView runat="server" Name="Detail1" DataSourceID="SqlDataSource2"  > 
                 
    <DetailTables> 
       <telerik:GridTableView runat="server" Name="Detail2" DataSourceID="SqlDataSource3"
         <Columns> 
                            
           <telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol" DataField="ProductName" > 
                          <ItemTemplate> 
                              <asp:Label ID="Label2" runat="server" Text='<%#Eval("ProductName") %>'></asp:Label> 
                          </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
 
       </Columns> 
                               
    </telerik:GridTableView> 
 </DetailTables>
......
........


CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if( (e.Item is GridDataItem)&&(e.Item.OwnerTableView.Name == "Detail2")) 
        {  
            GridDataItem item=(GridDataItem)e.Item; 
            Label lbl = (Label)item["TempCol"].FindControl("Label2"); 
            string strtxt = lbl.Text;  
        } 
    } 


Thanks
Shinu.
Tags
Grid
Asked by
John Martin
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or