conditional formatting on detailtable in hierarchy

2 posts, 0 answers
  1. Jeff
    Jeff avatar
    42 posts
    Member since:
    Jan 2008

    Posted 13 Oct 2009 Link to this post

    I've got a 2 level hierarchical grid and I need to set the formatting of certain rows in the child level. I've tried puttting the conditional formatting elements in the itemdatabound event for the overall grid and also in the detailtabledatabind. In each case it has a hard time finding the data element that sets the condition and I get a "cannot find a cell bound to column name..."

    Is there an example of how to set the format of a child row based on a data element within that row?

    For example if the child row has a data element called "Level" and if level for that row is "3" then the data element called "Name" would be orange...

    thanks for any guidance you can give
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Oct 2009 Link to this post

    Hello Jeff,

    You have to differentiate between the ownertableviews and then implement conditional formatting as shown below:
    <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" 
    runat="server" onitemdatabound="RadGrid1_ItemDataBound"
       <MasterTableView Name="Master"
             <telerik:GridTableView AutoGenerateColumns="false" Name="Detail" DataSourceID="SqlDataSource2"
                <telerik:GridBoundColumn DataField="Level" HeaderText="Level" UniqueName="Level"></telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name"></telerik:GridBoundColumn> 

    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
            if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail"
                GridDataItem item = (GridDataItem)e.Item; 
                if (item["Level"].Text == "3"
                    item["Name"].BackColor = System.Drawing.Color.Crimson; 

Back to Top