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

How get parent Id in detail OnQueryCreated?

1 Answer 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Susan
Top achievements
Rank 1
Susan asked on 22 Jul 2011, 05:27 PM
I have a master/detail radgrid tied to EntityDataSOurce controls.

I can't get the where clause to work so want to use OnQueryCreated for the details table to do the proper subsetting.

I have this working with a kludge by having ItemCommand "ExpandCollapse" save the Id of the parent record that I drill into in a sesison variable and then read that session variable in the OnQueryCreated event handler for the detail table. And that works but feels bad.

How can I get the parent item Id directly from OnQueryCreated?

If I try to access like this -

    rgrdStatus.MasterTableView.DetailTables[0].ParentItem.GetDataKeyValue(

 

"Id")

the ParentItem is always null!

Thanks!

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jul 2011, 08:51 AM
Hello Susan,

Try the following code snippet to access dataKeyValue which worked as expected.

C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
       if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "DetailTable1")
        {
            GridDataItem item = (GridDataItem)e.Item;
            string Id = item.OwnerTableView.ParentItem.GetDataKeyValue("ID").ToString();
        }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Susan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or