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