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

Master/Detail hierarchy binding via ObjectDataSource

4 Answers 244 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Louis
Top achievements
Rank 1
Louis asked on 07 Dec 2009, 06:22 PM


        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="ObjectDataSource1" GridLines="None" 
            Skin="Office2007" BorderStyle="Solid" BorderWidth="1pt">  
            <MasterTableView DataSourceID="ObjectDataSource1" AutoGenerateColumns="false" DataKeyNames="Datastore:ResultSummaryId">  
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="Datastore:ResultSummaryId" HeaderText="ID" HeaderStyle-Width="75pt">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="SummaryName" HeaderText="Name">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="AttemptRate Variations" HeaderText="Variation Attempt Rate" 
                        DataFormatString="{0:P}" HeaderStyle-Width="75pt" HeaderStyle-HorizontalAlign="Center" 
                        ItemStyle-HorizontalAlign="Right">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="PassRate Variations" HeaderText="Variation Pass Rate" 
                        DataFormatString="{0:P}" HeaderStyle-Width="75pt" HeaderStyle-HorizontalAlign="Center" 
                        ItemStyle-HorizontalAlign="Right">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="AttemptRate Results" HeaderText="Result Attempt Rate" 
                        DataFormatString="{0:P}" HeaderStyle-Width="75pt" HeaderStyle-HorizontalAlign="Center" 
                        ItemStyle-HorizontalAlign="Right">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="PassRate Results" HeaderText="Result Pass Rate" 
                        DataFormatString="{0:P}" HeaderStyle-Width="75pt" HeaderStyle-HorizontalAlign="Center" 
                        ItemStyle-HorizontalAlign="Right">  
                    </telerik:GridBoundColumn> 
                </Columns> 
                <DetailTables> 
                    <telerik:GridTableView DataSourceID="ObjectDataSource2" runat="server" 
                        AutoGenerateColumns="true">  
                        <ParentTableRelation> 
                            <telerik:GridRelationFields DetailKeyField="Datastore:ResultSummaryId" MasterKeyField="Datastore:ResultSummaryId" /> 
                        </ParentTableRelation> 
                    </telerik:GridTableView> 
                </DetailTables> 
            </MasterTableView> 
            <FilterMenu EnableTheming="True">  
                <CollapseAnimation Duration="200" Type="OutQuint" /> 
            </FilterMenu> 
        </telerik:RadGrid> 
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetTestPassSummaryByResultSummaryTo" 
            TypeName="ScratchWebApplication.ServiceReference1.AtlasReportingServiceClient">  
            <SelectParameters> 
                <asp:QueryStringParameter DefaultValue="WIN_CLIENT_UA:347184,WIN_CLIENT_UA:347194,WIN_CLIENT_UA:347845,WIN_CLIENT_UA:347866,WIN_CLIENT_UA:350235,WIN_CLIENT_UA:350237,WIN_CLIENT_UA:351070,WIN_CLIENT_UA:351082,WIN_CLIENT_UA:351098" 
                    Name="dataStoreRCIdCombos" QueryStringField="rc" Type="String" /> 
            </SelectParameters> 
        </asp:ObjectDataSource> 
        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetTestPassSummaryByResultSummaryTo" 
            TypeName="ScratchWebApplication.ServiceReference1.AtlasReportingServiceClient">  
            <SelectParameters> 
                <asp:SessionParameter SessionField="Datastore:ResultSummaryId" Name="dataStoreRCIdCombos" Type="String" DefaultValue="" /> 
            </SelectParameters> 
        </asp:ObjectDataSource> 

Pretty simple - I want to show rows in the master table that have only a few columns from the dataset, and if the user expands a row they can see all the columns from that same dataset for that row.  I'd like to know if this is possible without writing code-behind.  The ObjectDataSources come from a WCF service reference.  I was under the impression from something I read that the RadGrid adds thte DataKey/Value to the session state, which can then be dereferenced by the second ObjectDataSource.  Doesn't seem like that's the case.

Any ideas?

Thanks

4 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 10 Dec 2009, 04:22 PM
Hello Louis,

I examined your code and I prepared a sample project for you. There I used NestedViewTemplate instead of DetailTables. Then I kept the ID of the selected row in a hidden label which is a ControlParameter for the second ObjectDataSource.

I hope this helps.


Best wishes,
Radoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sal
Top achievements
Rank 1
answered on 03 Aug 2011, 04:57 PM
I know that this thread is rather old, however, I used it in order to fix an issue I was having. Now, after I applied the solution suggested here, I can no longer do anything with the master grid (sort/filter/page). Here is the thread I started for which I have not received any usefull help.

http://www.telerik.com/community/forums/aspnet-ajax/grid/sorting-filtering-not-working-with-hierarchy-using-nestedviewtemplate-which-loads-data-via-objectdatasource.aspx

Hopefully through this I can get more help.

Sal.
0
Accepted
Radoslav
Telerik team
answered on 08 Aug 2011, 01:31 PM
Hi Sal,

Could you please verify that into the NeedDataSource event handler you properly construct a data source object and assign it to the grid's DataSource property? You could check a following online documentation article which explains the Advanced Data-binding (using NeedDataSource event)
http://www.telerik.com/help/aspnet-ajax/grid-advanced-data-binding.html
Also could you please add the ObjectDataSource control before the FormView control in this way the ObjectDataSource will be created when the FormView is initialized and the exception : The DataSourceID of 'FormView' must be the ID of a control of type IDataSource..., will be avoided.

Additionally I am sending you a simple example based on your code. Please check it out and let me know if it helps you.

Looking forward for your reply.

Kind regards,
Radoslav
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
Sal
Top achievements
Rank 1
answered on 08 Aug 2011, 02:11 PM
Radoslav,

First of all, let me tell you two words: YOU ROCK!

I have been trying for over a week and the last thing I thought about was moving the datasource above the FormView. It may sound stupid once you see the solution but three different posts and a support ticket and yet had not been solved! You did in your first response with your suggestion and example. 

Thank you so much for taking the time to analyze the issue and use my code to create he example. I can honsestly say that you guys were trying hard to help me and that speaks very good of you. I am looking forward to a long relationship with Telerik. Keep it up guys. 

Once again, thanks for all the support.

By the way, how do I mark your answered as solution?

Sal 
Tags
Grid
Asked by
Louis
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Sal
Top achievements
Rank 1
Share this question
or