2014-04-22 4 views
0

이라는 열이있는 액세스 데이터베이스에 연결된 datagrid view이 있습니다. 해당 열의 셀이 준비로 변경되면이 셀의 배경색이 녹색으로 바뀌고 준비되지 않은 경우 빨간색으로 변경됩니다.데이터에 따라 특정 셀 색상을 변경하십시오.

제안 사항?

+0

당신은 데이터 그리드의'fetchrowStyle' 이벤트에이 작업을 수행 할 수있는 그리드보기의 RowDataBound 이벤트에 그렇게 할 수 –

답변

1

DataBound의 눈금에서 세포의 상태를 확인하고 세포의 색을 확인할 수 있습니다.

예 :이 당신을 도울 수

protected void grd_DataBound(object sender, EventArgs e) 
{ 
    foreach (GridViewRow GR in grd.Rows) 
    { 
     //Here run loop on your rows and check value of cell of column name Status 
     GR.Cells[index of cell].BackColor = System.Drawing.Color.Cyan; 
    } 
} 

희망.

0

당신은

protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e) 
    { 
     if (e.Row.RowType == DataControlRowType.DataRow) 
     { 
      //Check the status here 
      if (status == "ready") 
      { 
       e.Row.Cells[0].BackColor = System.Drawing.Color.Green; 
      } 
      else 
      { 
       e.Row.Cells[0].BackColor = System.Drawing.Color.Red; 
      } 
     } 
    } 
관련 문제