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

Master Table View DataKey Name in Detail Table

1 Answer 298 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ramakrishna
Top achievements
Rank 1
Ramakrishna asked on 01 Jul 2011, 08:23 AM
Hi
I need Datakeynames of master table view in detail table databind event.
Scenario:
i have 10 records in master table view each have its own key(ID) i added that key into datakey names in master table view.
i have detail table for each record so i need to get that datakey name in detail table to render my nested or detail or child grid.
thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 01 Jul 2011, 08:47 AM
Hello Ramakrishna,

Try the following code snippet to get the DataKeyNames of MasterTableView. Hope this helps.

C#:
protected void RadGrid2_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
        if (e.DetailTableView.Name == "DetailTable1")
        {
            GridTableView detailtabl1 = (GridTableView)e.DetailTableView;
            GridDataItem parentItem = (GridDataItem)detailtabl1.ParentItem;      
            string customerId = parentItem.GetDataKeyValue("CustomerID").ToString();//here CustomerID is the DataKeyName
      }
}

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