【发布时间】:2014-10-15 17:01:01
【问题描述】:
protected void getmessagelisting()
{
ds = new DataSet();
SQL = "Select * from [magaj].[message] where UId='" + Session["UserID"].ToString() + "' order by ID desc";
SqlDataAdapter da = new SqlDataAdapter(SQL, _connect());
da.Fill(ds, "message");
Grid_Joblist.DataSource = ds;
Grid_Joblist.Columns[0].Visible = true;
Grid_Joblist.DataBind();
Grid_Joblist.Columns[0].Visible = false;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (ds.Tables[0].Rows[i]["isread"].ToString() == "0")
{
// (e.Row.FindControl("lblsubject") as Label).ForeColor = Color.Yellow;
foreach (GridViewRow row in Grid_Joblist.Rows)
{
Label lblsubject = row.FindControl("lblsubject") as Label;
lblsubject.ForeColor = Color.Yellow;
}
}
}
}
现在当我运行它时,我将以正确的方式绑定所有数据
但是当我想做任何具有value of isread=0 的数据时,我想更改该标签的颜色。
但是当任何 1 行满足这个 if 条件时,它也会改变所有其他标签颜色..
如果标签颜色满足isread=0,我只想更改标签颜色,而对于其他不满足的数据,它将是不同的颜色
我该怎么做?
【问题讨论】:
-
当网格被重绘时,为什么不在那里做你的颜色逻辑..?
-
哪里可以写??