Locate grid within a grid

2 posts, 1 answers
  1. TippCityTom
    TippCityTom avatar
    14 posts
    Member since:
    Sep 2008

    Posted 02 Feb 2009 Link to this post



    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">












    <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>












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













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



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



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



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












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



















    <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" />





  2. Answer
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Feb 2009 Link to this post

    Hi Tomas,

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

    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 

Back to Top