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

GUID Not Being Passed to Detail Table

2 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brendan
Top achievements
Rank 1
Brendan asked on 28 May 2012, 09:05 PM
I have been attempting to get a detail table working connecting through a LINQ data source in a Grid. When I attempt to expand the detail table, the ID for the SelectParameter is being passed through as null. Does anyone know why this might be happening?

ASPX code:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="rgFacilities">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="rgFacilities" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid DataSourceID="ldsFacilities" AutoGenerateColumns="false" AllowPaging="True" PageSize="20" AllowSorting="True" ID="rgFacilities" runat="server">
    <MasterTableView DataKeyNames="FacilityID" DataSourceID="ldsFacilities" AllowMultiColumnSorting="False" GroupLoadMode="Server">
        <DetailTables>
            <telerik:GridTableView DataKeyNames="EquipmentID" DataSourceID="ldsEquipment" Width="100%"
                runat="server" AutoGenerateColumns="true">
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="FacilityID" MasterKeyField="FacilityID" />
                </ParentTableRelation>
            </telerik:GridTableView>
        </DetailTables>
        <Columns>
            <telerik:GridBoundColumn SortExpression="Name" HeaderText="Facility Name"
                DataField="Name" UniqueName="Name">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="City" HeaderText="City"
                DataField="City" UniqueName="City">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="Region" HeaderText="State/Province"
                DataField="Region" UniqueName="Region">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="Country" HeaderText="Country"
                DataField="Country" UniqueName="Country">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="Description" HeaderText="Description"
                DataField="Description" UniqueName="Description" AllowSorting="false">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
 
<asp:LinqDataSource ID="ldsFacilities" OnSelecting="ldsFacilities_Selecting" runat="server">
</asp:LinqDataSource>
<asp:LinqDataSource ID="ldsEquipment" OnSelecting="ldsEquipment_Selecting" runat="server">
    <SelectParameters>
        <asp:SessionParameter Name="FacilityID" SessionField="FacilityID"/>
    </SelectParameters>
</asp:LinqDataSource>

Data Source Selecting Code:

protected void ldsFacilities_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    Data.EcofitDataContext db = new Data.EcofitDataContext();
 
    e.Result = (from f in db.Facilities
                select f);
}
 
protected void ldsEquipment_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    Data.EcofitDataContext db = new Data.EcofitDataContext();
 
 
    e.Result = (from eq in db.Equipments
                where eq.FacilityID == Guid.Parse(e.SelectParameters["FacilityID"].ToString())
                select eq);
}

Any help would be greatly appreciated!

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 31 May 2012, 07:51 PM
Hi Brendan,

Attached you will find a sample RadGrid page where I demonstrated how you could access the required DataKeyID of the selected item. Please check it out and let me know if you need further assistance.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Brendan
Top achievements
Rank 1
answered on 01 Jun 2012, 06:34 PM
Hi Eyup,

That solution resolved my problem nicely, everything is working properly now!

Thanks!
Tags
Grid
Asked by
Brendan
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Brendan
Top achievements
Rank 1
Share this question
or