April 25, 2011

How to read GridView Cells value in ASP.Net

protected void gvCallHistory_RowDataBound(object sender, GridViewRowEventArgs e)
{
foreach (GridViewRow row in gvCallHistory.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToInt32(row.Cells[2].Text.ToString()) > 7)
{
row.BackColor = System.Drawing.Color.Red;
row.ForeColor = System.Drawing.Color.Yellow;
}
if ((row.Cells[0].Text.ToString() == row.Cells[1].Text.ToString()) && Convert.ToInt32(row.Cells[2].Text.ToString()) > 11)
{
row.BackColor = System.Drawing.Color.Green;
row.ForeColor = System.Drawing.Color.Yellow;
}
}
}
}

No comments:

Post a Comment