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

Locate grid within a grid

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
TippCityTom
Top achievements
Rank 1
TippCityTom asked on 02 Feb 2009, 08:11 PM

RadGrid

 

radGrid2 = RadGrid1.FindControl("RadGrid2") as RadGrid;

above code does not work, need to export data from inner grid to excel but does not exist programmically.
How do you find grid2 within grid1?

code below:

 

<

 

telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="False" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="MasterDataSource" GridLines="None" ShowStatusBar="true" Skin="Web20" Width="1280px">

 

 

 

 

 

<PagerStyle Mode="Slider" />

 

 

 

 

 

<MasterTableView runat="server" AllowMultiColumnSorting="True" AlternatingItemStyle-BackColor="AliceBlue" DataKeyNames="SI_YYYY,SI_MM,SI_DD" DataSourceID="MasterDataSource" PageSize="15" ItemStyle-HorizontalAlign="Left" AlternatingItemStyle-HorizontalAlign="Left">

 

 

 

 

 

<NestedViewTemplate>

 

 

 

 

 

<fieldset id="fieldset1" runat="server" style="padding: 10px;">

 

 

 

 

 

<legend style="padding: 5px;"><b>specimen drop offs for: </b>

 

 

 

 

 

<asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Italic="true" Text='<%# Eval("SI_DATE") %>' Visible="false"></asp:Label>

 

 

 

 

 

</legend>

 

 

 

 

 

<asp:Button ID="Button1" CssClass="button" Width="150px" Text="Export to Excel" OnClick="Button1_Click"

 

 

 

 

 

runat="server"></asp:Button>

 

 

 

 

 

 

<asp:SqlDataSource ID="DetailsDataSource" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"

 

 

ProviderName="<%$ AppSettings:providerName %>"

 

 

SelectCommand="SELECT * FROM V_VISITS WHERE si_date = :si_date">

 

 

 

 

 

<SelectParameters>

 

 

 

 

 

<asp:ControlParameter ControlID="Label1" Name="si_date" PropertyName="Text" Type="String" />

 

 

 

 

 

</SelectParameters>

 

 

 

 

 

</asp:SqlDataSource>

 

 

 

 

 

 

<telerik:RadGrid ID="RadGrid2" runat="server" AllowMultiRowSelection="False" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="DetailsDataSource" GridLines="None" HeaderStyle-Wrap="false" PageSize="10" ShowStatusBar="true" Skin="Web20">

 

 

 

 

 

 

<PagerStyle Mode="Slider" />

 

 

 


 

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 03 Feb 2009, 05:40 AM
Hi Tomas,

Try the below code snippets for accessing the RadGrid which is placed inside the nestedViewTemplat.

CS:
protected void Button1_Click(object sender, EventArgs e) 
{   
    foreach (GridNestedViewItem item in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView))  
    { 
        if (item.Visible == true
        { 
            RadGrid grid = (RadGrid)item.FindControl("RadGrid2"); //Access the RadGrid in NestedViewTemplate 
        }     
    }  

Thanks,
Shinu.
Tags
Grid
Asked by
TippCityTom
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or