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

Master Detail & ItemDataBound ... which one

4 Answers 221 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 27 Feb 2009, 12:15 AM
I have a RadGrid where I use the ItemDataBound event to modify the text displayed. I have a situation where the Master and Detail table have identical column names. I need to be able to tell which grid (Master or Detail) I'm dealing with in the ItemDataBound event.

It doesn't matter which grid is being binded, the same ItemDataBound code runs for both.

Thanks for you assistance.

Barry

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Feb 2009, 04:06 AM
Hi Barry,

You can use the "item.OwnerTableView.Name" property in the ItemDataBound to differentiate the Mater Table and Detail table 
Assign Name to the Master and Details and Check that in the code behind as show below

private void RadGrid1_ItemDataBound(object sender, Telerik.WebControls.GridItemEventArgs e)
{
       
//identify to which table belongs the currently bound item
        
if (e.Item.OwnerTableView.Name == "MyUniqueTableName")
       {
        
//process requested operations
       }

}

-Shinu.
0
Princy
Top achievements
Rank 2
answered on 27 Feb 2009, 04:09 AM
 
0
Barry
Top achievements
Rank 1
answered on 27 Feb 2009, 01:31 PM
Perfect!

I tried and failed to use the DataSourceName.

This works great!

Thanks for the advise.

Barry
0
Shinu
Top achievements
Rank 2
answered on 02 Mar 2009, 05:22 AM
Hi Barry,

You can also refer the following help document link which explains how to distinguish grid rows ina Hierarchical Grid.
Distinguish grid rows in hierarchy on ItemCreated/ItemDataBound

Shinu
Tags
Grid
Asked by
Barry
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Barry
Top achievements
Rank 1
Share this question
or