asp.net 网格视图行未显示在IE中

sqxo8psd  于 2023-01-22  发布在  .NET
关注(0)|答案(1)|浏览(245)

我正在开发一个asp页面,GridView的网格线在IE中没有显示,但在Firefox和Chrome中显示了。是否有一些具体的事情需要为IE端做。这是我的GridView的css文件:

/* 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属性上有GridLines ="Both"。我做错了什么?
谢谢你的帮助。

svujldwt

svujldwt1#

对于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";
   };
}

相关问题