protected void gvCities_RowDataBound(object sender, GridViewRowEventArgs e)
{
// Checking if row type
if (e.Row.RowType == DataControlRowType.DataRow)
{
// find the label control
Label lblSalary = e.Row.FindControl(“lblSalary”) as Label;
// read the value from the datasoure
Double Salary= Convert.ToDouble(Convert.ToString(DataBinder.Eval(e.Row.DataItem, “Rate”)));
if (Salary < 9000.00)
{
// get the cell where that label contains
DataControlFieldCell d = lblPrice.Parent as DataControlFieldCell;
// to change the backcolor
d.BackColor = System.Drawing.Color.Blue;
// to change the row color by setting
e.Row.BackColor = System.Drawing.Color.Red;
// to change the text color like this
lblPrice.ForeColor = System.Drawing.Color.Green;
}
}
}