Is the Html.Grid() customized by yourselv? If it is, you can customize the style for it according to your requirement.
Or else you have to check the grid to see whether some functions or propertys are supplied to change the style of one cell. If no one exists, maybe we can't do it.
Salvatore Di...
Member
19 Points
76 Posts
Html.Grid().Columns() set colors on cell
Oct 08, 2009 10:06 AM|LINK
Hi guys,
I would like to change the color in a cell when the record I had rendered match a condition.
How can I do that?
tnx
http://bitvector.tostring.it
leena.d.pati...
Member
430 Points
79 Posts
Re: Html.Grid().Columns() set colors on cell
Oct 09, 2009 07:29 AM|LINK
Hi, try following-
GridView1.Rows[1].Cells[0].BackColor = System.Drawing.Color.Blue;
Leena
Please remember to mark replies as answers if you find them useful.
karnanaspnet...
Member
122 Points
36 Posts
Re: Html.Grid().Columns() set colors on cell
Oct 09, 2009 07:39 AM|LINK
Hi,
In RowCreated or RowDatabound
Try something like this
if (e.Row.RowType == DataControlRowType.DataRow)
{
int intsomeitem= (int)DataBinder.Eval(e.Row.DataItem, "someitem");
if (intsomeitem== 0)
{
e.Row.BackColor = System.Drawing.Color.LightPink;
e.Row.ForeColor = System.Drawing.Color.Maroon;
}
else if (intsomeitem== 1)
{
e.Row.BackColor = System.Drawing.Color.LightCyan;
e.Row.ForeColor = System.Drawing.Color.DarkBlue;
}
else
{
e.Row.BackColor = System.Drawing.Color.LightGray;
e.Row.ForeColor = System.Drawing.Color.Red;
}
}
KeFang Chen ...
Star
8329 Points
852 Posts
Re: Html.Grid().Columns() set colors on cell
Oct 12, 2009 06:44 AM|LINK
Hi,
Is the Html.Grid() customized by yourselv? If it is, you can customize the style for it according to your requirement.
Or else you have to check the grid to see whether some functions or propertys are supplied to change the style of one cell. If no one exists, maybe we can't do it.