2010-05-08 61 views

回答

1
<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,索引等

+0

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

+0

(e.Row.Cells [statusFieldIndex] .Text ==「A」)在本文中與列標題文本進行比較。但我想比較綁定數據(A) - – user260997 2010-05-08 06:07:00

+0

e.Row.DataItem包含源數據 – heisenberg 2010-05-08 13:49:18

相關問題