2
我正在填充一個數據表,然後將它綁定到一個gridview。現在我正在讀取網格中的行併爲行if value = [x]
着色。asp.net gridview如果單元格的行值相等然後
當我嘗試在頁面上顯示彩色的行時,我會重複它。 可以說,我有1行的顏色,但response.write
將像100次相同的結果。 下面是我的代碼,希望有人能幫助:
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
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"]);
}