2012-02-23 58 views
1

我正在開發一個asp頁面,並且GridView GridLines沒有在IE中顯示,但它顯示在Firefox和Chrome上。 IE端需要做些什麼? 這是我的GridView的css文件:GridView行不在IE中顯示

 
     /* grid table */ 
     table.gridview { border-collapse: collapse; margin: 0px !important; border: #6593CF 1px solid; } 
     .gridview td { font-size: 11px; font-family: Arial; color: #000000; cursor: default; text-align: left; } 
     .gridview th { font-size: 11px; font-family: Arial; color: #484848; cursor: default; text-align: left; } 
     table.gridview a { color: #000000; text-decoration: none; } 
     table.gridview a:hover { text-decoration: underline; } 

     /* header row */ 
     tr.gridview_hdr { background-color: #DEECFF; } 
     .gridview_hdr th { color: black; font-weight: normal; text-align: left;border-top: solid 1px #6593CF; border-bottom: solid 1px #6593CF; border-left: solid 1px #6593CF; border-right: solid 1px #6593CF; padding-left: 5px; padding-right: 5px; padding-top: 2px; padding-bottom: 2px; } 
     .gridview_hdr th a { color: #000000; text-decoration: none; font-weight: bold; } 
     .gridview_hdr th a:hover { color: #000000; text-decoration: underline; } 

     /* item row */ 
     tr.gridview_itm { background-color: #FFFFFF; } 
     .gridview_itm td { padding: 2px 5px; border-right: #FFFFFF 0px solid; border-top: #FFFFFF 1px solid; border-left: #FFFFFF 0px solid; border-bottom: #ADD1FF 1px solid; } 
     .gridview_itm td a { text-decoration: underline; } 

     /* alternating item row */ 
     tr.gridview_aitm { background-color: #FFFFFF; } 
     .gridview_aitm td { padding: 2px 5px; border-right: #FFFFFF 0px solid; border-top: #FFFFFF 1px solid; border-left: #FFFFFF 0px solid; border-bottom: #ADD1FF 1px solid; } 
     .gridview_aitm td a { text-decoration: underline; } 

     /* pager row */ 
     tr.gridview_pgr { width : 100%; 
          font-family:verdana; 
          font-weight: bold; 
          font-size: 11pt; 
          color: #ff9900;      
         } 
     .gridview_pgr td { background-image: url(/Monitor/App_Themes/Sugar2006/images/bg.gif); background-repeat: repeat-x; height: 23px; padding: 0px; font-size: 10px; font-family: Arial; } 
     .gridview_pgr_ddl { font-size: 10px; font-family: Arial; } 
     .gridview_pgr A{ 
      font-family:verdana; 
      font-size: 9pt; 
      text-decoration: none; 
      color: #0000ff;     
      } 

,這是我的aspx頁面:

 
     asp:GridView 
      ID="GridView1" 
      runat="server" 
      CssClass="gridview" 
      RowStyle-CssClass="gridview_itm" 
      AlternatingRowStyle-CssClass="gridview_aitm" 
      HeaderStyle-CssClass="gridview_hdr" 
      PagerStyle-CssClass="gridview_pgr" 
      AutoGenerateColumns="False" 
      AllowPaging="True" PageSize="50" Width="100%" AllowSorting="True" 
      onsorting="GridView1_Sorting" onrowdatabound="gridView1_RowDataBound" 
      onpageindexchanging="GridView1_PageIndexChanging"> 

而且我有網格線= 「兩者」 的GridView控件屬性。 我在做什麼錯?

感謝您的幫助。

+0

如果您發佈原始HTML,那麼我們這些無法讀取ASPX的人可以提供幫助。 – KatieK 2012-02-23 22:31:45

+0

我沒有HTML代碼,所有可用於此問題的asp.net代碼。 – 2012-02-23 22:45:48

+0

當然,Firefox,Chrome和IE正在閱讀HTML? – KatieK 2012-02-23 22:48:18

回答

3

使用GridView,聲明式bordercolor屬性添加了內聯樣式聲明,該聲明僅適用於表格本身,而不適用於單個單元格。

以編程方式添加bordercolor屬性不使用內聯樣式,但使用HTML bordercolor屬性,這些瀏覽器適用於表內的所有邊界。

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    foreach (TableCell tc in e.Row.Cells) 
    { 
    tc.Attributes["style"] = "border-color: #c3cecc"; 
    }; 
} 
+0

這仍然不顯示網格線:( – 2012-02-27 14:38:49

+0

更新的答案 - 這應該工作,但評論首先將樣本中的所有CSS - 過度殺傷。 – IrishChieftain 2012-02-27 15:07:07

+0

僅供參考...我將代碼移至RowDataBound處理程序,但原始代碼應該適用於您,這就是爲什麼我建議註釋掉上面示例中的所有CSS,或者更好的是,用網格創建一個簡單的測試頁面:) – IrishChieftain 2012-02-27 15:52:55