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

distinguishing "master rows" from "detail rows"

3 Answers 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 05 Nov 2008, 09:59 AM
I have code:
 void tradeRadGrid_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridDataItem) 
            { 
                DataRowView drv = e.Item.DataItem as DataRowView; 
                if (drv != null
                { 
                    if (drv["Difference"] != DBNull.Value) 
                    { 
                        int dif; 
                        int.TryParse(drv["Difference"].ToString(), out dif); 
                        TableCell tc = (e.Item as GridDataItem)["Difference"]; 
                        if (dif > 0) 
                        { 
                            tc.BackColor = Color.FromArgb(176, 251, 159); 
                        } 
                        else if(dif < 0) 
                        { 
                            tc.BackColor = Color.FromArgb(255, 176, 159); 
                        } 
                    } 
                } 
            } 
        } 
My question:
How Can I distinguish MasterTableViewitems from DetailTables items durring ItemDataBound? I would like to chnage data for MasterTableView item, not for DetailTables item.


3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 05 Nov 2008, 10:35 AM
Hello Mark,

The most easiest way is to differentiate the table by its name as shown below:

<MasterTableView Name="myMasterTableView" ... > 

<telerik:GridTableView Name="myDetailTable1" ...

if (e.Item.OwnerTableView.Name == "myMasterTableView"
{  
    ... 
 

I hope this helps.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mark
Top achievements
Rank 1
answered on 05 Nov 2008, 11:40 AM
Thank You very much, it works great.
0
Shinu
Top achievements
Rank 2
answered on 05 Nov 2008, 12:28 PM
Hi Mark,

You can also refer the following help article which explains the same.
Distinguish grid rows in hierarchy on ItemCreated/ItemDataBound

Thanks
Shinu.
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Mark
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or