2010-05-08 3 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; if (e.Row.Cells [statusFieldIndex] .Text == "A") { e.Row.BackColor = Color.Red; } // 등 } statusFieldIndex가 함유 필드 인덱스, L, P 등으로 설정 될 경우 (e.Row.Cells [statusFieldIndex]는 .text == "A")에서 이 텍스트는 열 헤더 텍스트와 비교됩니다. 하지만 바인딩 데이터 (A) – user260997

+0

(e.Row.Cells [statusFieldIndex] .Text == "A")을 비교하고 싶습니다.이 텍스트에서 열 헤더 텍스트와 비교하고 있습니다. 하지만 바인딩 데이터 (A)를 비교하고 싶습니다 - – user260997

+0

e.Row.DataItem 소스 데이터가 포함되어 있습니다 – heisenberg

관련 문제