0
我在sqlview中显示Gridview中的学生出勤。我选择A作为A,呈现为P,并且保留为L.现在,我想要以红色显示A,在Gridview数据绑定中以绿色显示P,而不是标题文本。怎么样。请帮帮我不同颜色的gridview中的数据显示取决于asp.net中的文本
我在sqlview中显示Gridview中的学生出勤。我选择A作为A,呈现为P,并且保留为L.现在,我想要以红色显示A,在Gridview数据绑定中以绿色显示P,而不是标题文本。怎么样。请帮帮我不同颜色的gridview中的数据显示取决于asp.net中的文本
<asp:GridView ID="studentGridView" runat="server" OnRowDataBound="studentGridView_RowDataBound"/>
protected void studentGridView_RowDataBound(Object sender,GridViewRowEventArgs e)
{
const int statusFieldIndex = 1;
if (e.Row.Cells[statusFieldIndex].Text == "A")
{
e.Row.BackColor = Color.Red;
}
//etc
}
statusFieldIndex将被设置为字段的含有A,L,P,索引等
的 protected void studentGridView_RowDataBound(Object sender,GridViewRowEventArgs e) const int statusFieldIndex = 1; (e.Row.Cells [statusFieldIndex] .Text ==“A”) {e.Row.BackColor = Color.Red; } //等 } statusFieldIndex将被设置为字段的含有A的索引,L,P,等 如果(e.Row.Cells [statusFieldIndex]。文本== “A”) 在此文本与列标题文本进行比较。但我想比较绑定数据(A) –
user260997
2010-05-08 05:59:42
(e.Row.Cells [statusFieldIndex] .Text ==“A”)在本文中与列标题文本进行比较。但我想比较绑定数据(A) - – user260997 2010-05-08 06:07:00
e.Row.DataItem包含源数据 – heisenberg 2010-05-08 13:49:18