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

Format the first three rows of a telerik radgrid

4 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ufuoma
Top achievements
Rank 1
Ufuoma asked on 28 Nov 2012, 07:24 AM
Hi,

I am working on a project and I want to change the forecolor of the first three rows of the radgrid and also make it bold so as to show that those top three records are the leading results in the radgrid.

Please help with how I can achieve this.

Thanks

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Nov 2012, 07:58 AM
Hi,

You can set the forecolor and font size in ItemDataBound event as shown below.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
   GridDataItem item = (GridDataItem)e.Item;
   if (item["Uniquename"].Text == "text")
   {
       item.ForeColor = System.Drawing.Color.Red;
       item.Font.Bold = true;
   }
  }
}

Thanks,
Shinu.
0
Ufuoma
Top achievements
Rank 1
answered on 28 Nov 2012, 08:09 AM
Thanks Shinu.

What do you mean by '[Unique name].Text'... It is throwing an error.

Please can you give me the exact code for formatting the top 3 rows of the radgrid because I do not know how to customize the code you posted earlier.

Thanks
0
Ufuoma
Top achievements
Rank 1
answered on 28 Nov 2012, 08:16 AM
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                if (item.RowIndex <=2)
                {
                    item.ForeColor = System.Drawing.Color.Red;
                    item.Font.Bold = true;
                }
            }
        }

But its not working properly.
0
Princy
Top achievements
Rank 2
answered on 29 Nov 2012, 06:52 AM
Hi,

You can set the forecolor using ItemIndex as shown below.
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        if (item.ItemIndex <=2)
        {
            item.ForeColor = System.Drawing.Color.Red;
            item.Font.Bold = true;
        }
    }
}

Thanks,
Princy.
Tags
Grid
Asked by
Ufuoma
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ufuoma
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or