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

RadGrid inside MultiPage inside NestedView

2 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cole
Top achievements
Rank 1
Cole asked on 24 Mar 2011, 09:47 AM
I have an RadGrid (RadGrid2) inside a MultiPage that is in turn inside a NestedViewTemplate on a parent RadGrid (RadGrid1).  I need to use the NeedDataSource of RadGrid2 because I am doing inline editing of the items inside that grid.  The binding is relient on the DataKeyValue of the parent row of RadGrid1.  What I am wondering is what is the best approach to retrieving the DataKeyValue of the row from RadGrid1 from the NeedDataSource event of RadGrid2.

Any help would be greatly appreciated as I am on a deadline and I have been struggling with this for a couple hours now.

Thanks!

Cole

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Mar 2011, 10:31 AM
Hello Cole,

The following code snippet will help you to achieve this.

C#:
protected void RadGrid2_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        GridDataItem parentItem = ((sender as RadGrid).NamingContainer as GridNestedViewItem).ParentItem as GridDataItem;
        string keyValue = parentItem.GetDataKeyValue("ID").ToString();//getting parent DataKeyValue
    }

Thanks,
Princy.
0
Cole
Top achievements
Rank 1
answered on 24 Mar 2011, 12:12 PM
Thank you so much! That worked like a charm!
Tags
Grid
Asked by
Cole
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Cole
Top achievements
Rank 1
Share this question
or