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

AlternatingItemStyle and DetailTables

5 Answers 214 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erin
Top achievements
Rank 1
Erin asked on 13 Aug 2012, 01:26 PM
I have a MasterTable which uses DetailTables (in a RadGrid). The MasterTable uses AlternatingItemStyle to color every other row in the grid. The problem is that this color does not come down into the DetailTables (i.e. every other main row is colored, but ALL DetailTables are white/uncolored). I need each DetailTable to match the color/background of its associated row in the grid. Any suggestions?

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Aug 2012, 04:47 AM
Hi,

One suggestion is that you can set color for DetailTables as shown below.
aspx:
<telerik:RadGrid  AlternatingItemStyle-BackColor="Red">  
 <DetailTables>
    <telerik:GridTableView AlternatingItemStyle-BackColor="Red">
      . . .
    </telerik:GridTableView>
 </DetailTables>
</telerik:RadGrid>

Thanks,
Shinu.
0
Erin
Top achievements
Rank 1
answered on 14 Aug 2012, 01:34 PM
That looks like it could work! Thank you! I should mention that I need to do this through the code behind (C#). Any other suggestions?
0
Shinu
Top achievements
Rank 2
answered on 16 Aug 2012, 05:13 AM
Hi,

You can set color in ItemDataBound event as shown below.
aspx:
<DetailTables>
   <telerik:GridTableView Name="DetailTable1" . . >
</DetailTables>
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "DetailTable1")
 {
  GridTableView detailTable = (GridTableView)e.Item.OwnerTableView;
  detailTable.AlternatingItemStyle.BackColor = System.Drawing.Color.Red;
 }
}

Thanks,
Shinu.
0
Erin
Top achievements
Rank 1
answered on 16 Aug 2012, 01:13 PM
Thank you so much for your help, Shinu. Even copying this code, I still only ever get the main rows to alternately color - never the detail tables. I can either get all detail tables colored or none of them, but never alternating. I have tried every code modification I can think of. Do you think this could be a bug?

I've attached two screenshots. (Please ignore the fact that red is NOT the ultimate color choice, but is just being used for demonstrative purposes! :) The first screenshot is what I get with the code provided above. The second screenshot shows the part that I need colored, but, as you can see, every detail table is colored instead of every other one. 
0
Andrey
Telerik team
answered on 21 Aug 2012, 12:11 PM
Hi,

You could check this help topic for more information on how to change the Row appearance of RadGrid.

Additionally, if you are experiencing problems, please share your full page source code and along with the code-behind file. Thus all the people who want to help you will have better understanding of your project.

Kind regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Erin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Erin
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or