Wednesday, 8 October 2014

Highlight values in Gridview using Rowdatabound in ASP.NET

  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label chk1 = (Label)e.Row.FindControl("Label9");
            if (!string.IsNullOrEmpty(chk1.Text))
            {
                if (chk1.Text == "Approved")
                {
                    e.Row.Cells[9].ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    e.Row.Cells[9].ForeColor = System.Drawing.Color.Red;
                }
            }
        }
}


No comments:

Post a Comment