M
Mike P
I know how to get at different controls in a gridview using FindControl,
and I can change the forecolor or backcolor of the control in the
RowDataBound event (see below). But what I want to do is make reference
to the whole cell and change it's backcolor depending upon the value in
the cell. Is this possible?
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label ForecastType =
(Label)e.Row.FindControl("lblForecastType");
switch (ForecastType.Text)
{
case "Analysis":
ForecastType.BackColor =
System.Drawing.Color.LightBlue;
break;
case "Call Centre":
ForecastType.BackColor =
System.Drawing.Color.Yellow;
break;
case "Data":
ForecastType.BackColor = System.Drawing.Color.Cyan;
break;
case "Data/Analysis":
ForecastType.BackColor =
System.Drawing.Color.LimeGreen;
break;
}
}
and I can change the forecolor or backcolor of the control in the
RowDataBound event (see below). But what I want to do is make reference
to the whole cell and change it's backcolor depending upon the value in
the cell. Is this possible?
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label ForecastType =
(Label)e.Row.FindControl("lblForecastType");
switch (ForecastType.Text)
{
case "Analysis":
ForecastType.BackColor =
System.Drawing.Color.LightBlue;
break;
case "Call Centre":
ForecastType.BackColor =
System.Drawing.Color.Yellow;
break;
case "Data":
ForecastType.BackColor = System.Drawing.Color.Cyan;
break;
case "Data/Analysis":
ForecastType.BackColor =
System.Drawing.Color.LimeGreen;
break;
}
}