Sunday, 29 September 2013

asp.net gridview if cell row value is equal then

asp.net gridview if cell row value is equal then

i am populating a datatable then binding it to a gridview , now im readin
the rows in the grid and coloring the row if value = [x] the thing when i
try to display on the page the row that is colored im getting it
duplicated lets say i have colored 1 row but the response.write will be
like 100 times the same result , below is my code , hope some one can help
:
protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
string alert = Request.QueryString["check"];
// loop over all the Rows in the Datagridview
foreach (GridViewRow row in gv1.Rows)
{
// if condition is met color the row text and send email
if (gv1.Rows[0].Cells[0].Text.ToString() == alert)
{
Session ["fn"] = gv1.Rows[0].Cells[2].Text;
gv1.Rows[0].ForeColor = Color.Red;
}
Response.Write(Session["fn"]);
}

No comments:

Post a Comment