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

Bind NestedViewTemplate from code behind

8 Answers 280 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ajay
Top achievements
Rank 1
Ajay asked on 30 May 2011, 01:32 PM
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>

8 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 30 May 2011, 03:07 PM
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.

0
Ajay
Top achievements
Rank 1
answered on 31 May 2011, 06:39 AM
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

0
Ajay
Top achievements
Rank 1
answered on 31 May 2011, 09:06 AM
Hi Pavlina,

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

Ajay
0
Pavlina
Telerik team
answered on 31 May 2011, 02:36 PM
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.

0
Silvio Silva Junior
Top achievements
Rank 2
answered on 19 Jul 2013, 09:04 PM
thanks!
0
Jahanzaib
Top achievements
Rank 1
answered on 14 Feb 2014, 05:54 PM
Great. you saved me.
Thanks it worked for me. especially the sample was very helpful for me
0
neb
Top achievements
Rank 1
answered on 29 May 2014, 09:34 PM
Can you please post how you solved the send issue?
0
Makunda
Top achievements
Rank 1
answered on 26 Jul 2016, 06:09 PM
Could i know the fix for this?
Tags
Grid
Asked by
Ajay
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Ajay
Top achievements
Rank 1
Silvio Silva Junior
Top achievements
Rank 2
Jahanzaib
Top achievements
Rank 1
neb
Top achievements
Rank 1
Makunda
Top achievements
Rank 1
Share this question
or