Bind NestedViewTemplate from code behind

9 posts, 1 answers
  1. Ajay
    Ajay avatar
    42 posts
    Member since:
    Jul 2010

    Posted 30 May 2011 Link to this post

    Hi,
    I have a RadGrid (parent) which is having another radGrid (child) inside the NestedViewTemplate.
    I am providing the datasource of parent from code behind need datasource.

    How can I bind the child radgrid from codebehind based upon the a column/datakey value of the parent grid?

    In below code I have to fill the child grid with the  values sent by OAHSSQ column.



    <telerik:RadGrid ID="radGridShippedOrders" runat="server" GridLines="None" AllowPaging="True"
                PageSize="10" AllowSorting="True" AutoGenerateColumns="false" ShowStatusBar="true"
                HorizontalAlign="NotSet" AllowMultiRowEdit="false" OnNeedDataSource="radGridShippedOrders_NeedDataSource" 
                OnItemDataBound="radGridShippedOrders_ItemDataBound" OnItemCommand="radGridShippedOrders_OnItemCommand"
                Width="800px" AllowMultiRowSelection="False" AllowFilteringByColumn="true" ShowGroupPanel="True">
                <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
                
                <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
                     <Pdf PageTitle="Shipped Orders" />
                </ExportSettings>


                <MasterTableView GroupLoadMode="Client" CommandItemDisplay="Bottom" DataKeyNames="OAHSSQ" Name="MTVShippedOrders">
                    <CommandItemTemplate>
                        <asp:Button ID="DownloadPDF" runat="server" CommandName="ExportToPdf" Text="Export" />
                    </CommandItemTemplate>
                    <CommandItemSettings ShowExportToExcelButton="true" />
                    <Columns>
                        <telerik:GridBoundColumn UniqueName="OACONO" HeaderText="OACONO" DataField="OACONO">
                        </telerik:GridBoundColumn>                
                        <telerik:GridBoundColumn UniqueName="OAINNO" HeaderText="OAINNO" DataField="OAINNO">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName="OAORNO" HeaderText="OAORNO" DataField="OAORNO">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName="OAORGN" HeaderText="OAORGN" DataField="OAORGN">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn UniqueName="OAHSSQ" HeaderText="OAHSSQ" DataField="OAHSSQ">
                        </telerik:GridBoundColumn>
                                         
                    </Columns>
                    
                    <NestedViewTemplate>
                    
                        <telerik:RadGrid ID="radGridInvoiceHeader" runat="server" GridLines="None" AllowPaging="True"
                            PageSize="20" AllowSorting="True" AutoGenerateColumns="true" ShowStatusBar="true"
                            HorizontalAlign="NotSet" AllowMultiRowEdit="false" 
                            Width="100%" AllowMultiRowSelection="False" AllowFilteringByColumn="false">
                            <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
                        </telerik:RadGrid>

    </NestedViewTemplate>
                                    
                    
                </MasterTableView>
                 <ClientSettings AllowGroupExpandCollapse="True" ReorderColumnsOnClient="True" AllowDragToGroup="True"
                    AllowColumnsReorder="True">
                </ClientSettings>
                 <GroupingSettings ShowUnGroupButton="true" />
            </telerik:RadGrid>
  2. Answer
    Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 30 May 2011 Link to this post

    Hello Ajay,

    I have attached a sample project demonstrating how you can achieve the desired functionality. Have a look at it and let me know if it works for you.

    I hope this helps.

    Regards,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ajay
    Ajay avatar
    42 posts
    Member since:
    Jul 2010

    Posted 31 May 2011 Link to this post

    Hi Pavlina,

    Thanks for the solution, it worked perfectly.

    Now I am facing a little problem while implementing this with multiple grids.
    Actually I have 2 RadGrids inside the NestedViewTemplate, i.e. childGrid1 and childGrid2, I have implemented NeedDataSource for both of these.

    Now there is a scenario, if the expand button is clicked first time in the parent grid, then the NeedDataSource of only the childGrid1 gets called and the childGrid2 displays no data as it's event was not called.
    But for the next expand click commands NeedDataSource of both is called.

    Can you please help me in this??

    Thanks & Regards
    Ajay

  5. Ajay
    Ajay avatar
    42 posts
    Member since:
    Jul 2010

    Posted 31 May 2011 Link to this post

    Hi Pavlina,

    I have solved the issue myself, thanks for your time and support.

    Ajay
  6. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 31 May 2011 Link to this post

    Hi Ajay,

    I am glad that you were able to resolve the issue. In case you have additional questions or problems,do not hesitate to contact us again.

    Kind regards,
    Pavlina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  7. Silvio Silva Junior
    Silvio Silva Junior avatar
    100 posts
    Member since:
    Mar 2010

    Posted 19 Jul 2013 Link to this post

    thanks!
  8. Jahanzaib
    Jahanzaib avatar
    3 posts
    Member since:
    Feb 2014

    Posted 14 Feb 2014 in reply to Pavlina Link to this post

    Great. you saved me.
    Thanks it worked for me. especially the sample was very helpful for me
  9. neb
    neb avatar
    3 posts
    Member since:
    Jul 2011

    Posted 29 May 2014 Link to this post

    Can you please post how you solved the send issue?
  10. Makunda
    Makunda avatar
    1 posts
    Member since:
    May 2016

    Posted 26 Jul Link to this post

    Could i know the fix for this?
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017