2012-12-04 2 views

답변

4

: 당신은 또한 (tc.CssClass를 통해) CSS 클래스를 사용할 수 있습니다 물론

protected void gridView1_RowDataBound(Object sender, GridViewRowEventArgs e) 
{ 
    foreach (TableCell tc in e.Row.Cells) 
    { 
     tc.Attributes["style"] = "border-right:3px solid red; border-bottom:3px solid blue"; 
    } 
} 

을 대신 인라인 CSS.

+0

유용한 솔루션을 제공해 주셔서 감사합니다. –

0

당신은 RowDataBound 이벤트 같은 것을하여 변경할 수 있습니다 : 당신은 RowDataBound 사용할 수 있습니다

protected void grid_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    // check if it's a data row (not header and footer) 
    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
     // take a color from a condition or not... i don't know what is your case 
     string color = condition ? "#ff9900" : "some-other-color"; 

     // set the color on X column, where X is your column index (starting by 0) 
     e.Row.Cells[X].Attributes.Add("Style", "background-color: " + color + ";"); 
    } 
} 
1

모든 테두리를 제거하고 다음을 수행하십시오. 격자보기 태그에 다음 코드 줄을 추가하십시오.

CellPadding="4" CellSpacing="1" Height="100%" GridLines="None" BackColor="#9CB6DB" 

필요한 결과를 얻을 수 있습니다.

0

단순한 유 사용할 수도

<asp:GridView ID="grd_data" runat="server" GridLines="Both" CssClass="griedline"> </asp:GridView> 

으로 그리드 뷰 속성을 사용하여 특정 수평

외부 파일 또는 인라인 같은 스타일 시트의 CSS를 만들고 수직

.griedline tr,.griedline td,.griedline th 
     { 
      border-top: 1px solid #DDDDDD; 
      border-bottom: 1px solid #DDDDDD; 
      border-left:1px solid #DDDDDD; 
      border-right:1px solid #DDDDDD; 

     }