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

[Solved] Get parent key in nested grid

1 Answer 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 30 Nov 2009, 05:18 PM
Hello,

I've got this nested grid...

                            <telerik:GridTableView Name="gridMembershipComponents" runat="server"  CommandItemDisplay="Top" 
                                DataKeyNames="MembershipID, MembershipComponentID" DataSourceID="dsMembershipComponents"
                                <ParentTableRelation> 
                                    <telerik:GridRelationFields MasterKeyField="MembershipID" DetailKeyField="MembershipID" /> 
                                </ParentTableRelation> 
                                <Columns> 
                                    <telerik:GridDropDownColumn DataSourceID="dsAvailableMembershipComponents" ListTextField="Component" ListValueField="ComponentID" DataField="ComponentID" 
                                        HeaderText="Organization" SortExpression="Component" UniqueName="Component"
                                    </telerik:GridDropDownColumn> 
                                    <telerik:GridBoundColumn DataField="PaymentStatus" HeaderText="Status"  
                                        ReadOnly="True" SortExpression="PaymentStatus" UniqueName="PaymentStatus"
                                    </telerik:GridBoundColumn> 
                                </Columns> 
                            </telerik:GridTableView> 
                <asp:SqlDataSource ID="dsAvailableMembershipComponents" runat="server" 
                    ConnectionString="<%$ ... %>" 
                    SelectCommand="SELECT..."
                    <SelectParameters> 
                        <asp:Parameter Name="MembershipID" DefaultValue="0" Type="Int32" /> 
                    </SelectParameters> 
                </asp:SqlDataSource> 

The problem is that the MembershipID parameter doesn't seem to be getting a value. It should just get it from the grid - I thought...

Am I just totally missing something here? To give some quick context, I only copied in those parts... the parent grid has membershipID as the one and only key. I also deleted the sql statement and the connection string - I've seen in the code that the parameter is coming through as 0.

Any thoughts? I'm probably just mixed up on something totally basic...

Thanks,

Mike

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Dec 2009, 08:33 AM
Hello Mike,

You should either set the DataSourceId for the column as that of the GridTableView's DataSourceID or manually set the Parameter from code behind since in your case the parameter value will only affect the childtable and not the column with another DataSource.

Thanks
Princy.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or