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

Radgrid Background Color in Groupwise data

2 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
bony patel
Top achievements
Rank 1
bony patel asked on 06 Jun 2011, 07:09 AM
Hello all,

I use radgrid in my website, UI is really looking good.
But I want alternate Background color in all groupwise data please help me how can I implement in code behind.

Thankx in Advance
Bony

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 Jun 2011, 10:47 AM
Hello Bony,

Try the following code to set alternating color for grouped items in PreRender event. Hope this helps you.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
      int i = 0;
   foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))//accessing header
  {
        i++;
         GridItem[] children = groupHeader.GetChildItems();//accessing child items
            foreach (GridDataItem child in children)
            {
            GridDataItem childItem = child as GridDataItem;
                if (i % 2 == 0)
                {
                    childItem.BackColor = System.Drawing.Color.Red;
                }
                else
                {
                    childItem.BackColor = System.Drawing.Color.Black;
                }
                 }
        }
}



Thanks,
Shinu.
0
bony patel
Top achievements
Rank 1
answered on 06 Jun 2011, 11:17 AM
Hello Shinu,
Thank You, Code working nicely
Tags
Grid
Asked by
bony patel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
bony patel
Top achievements
Rank 1
Share this question
or