gpt4 book ai didi

c# - asp.net gridview 如果单元格行值相等则

转载 作者:太空宇宙 更新时间:2023-11-03 13:34:36 25 4
gpt4 key购买 nike

我正在填充数据表,然后将其绑定(bind)到 GridView 。现在我正在读取网格中的行并为行着色 if value = [x]

当我尝试在页面上显示彩色行时,我得到了复制。假设我已经为 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"]);
}

最佳答案

protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
string alert = Request.QueryString["check"];

if (e.Row.Cells[0].Text.ToString() == alert)
{
Session ["fn"] = e.Rows.Cells[2].Text;
e.Rows.ForeColor = Color.Red;

Response.Write(Session["fn"]);
}
}

关于c# - asp.net gridview 如果单元格行值相等则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19076322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com