gridview的编辑状态下样式不受控制的问题

来自:http://zhidao.baidu.com/question/61114429

 

方法一:在代码里page_load 加一段:GridView1.Attributes.Add("style", "table-layout:fixed");

方法二:给你一段样式:
<head runat="server">
<link href="css/main.css"  type="text/css"/>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    <title>无标题页</title>
     <style type="css/css">
.Freezing
   {
  
   position:relative ;
   table-layout:fixed;
   top:expression(this.offsetParent.scrollTop); 
   z-index: 10;
   }

.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}
       .FixedTitleRow
        {
            position: relative;
            top: expression(this.offsetParent.scrollTop);
            z-index: 10;
            background-color: #E6ECF0;
        }
       
        .FixedTitleColumn
        {
            position: relative;
            left: expression(this.parentElement.offsetParent.scrollLeft);
        }
       
        .FixedDataColumn
        {
            position: relative;
            left: expression(this.parentElement.offsetParent.parentElement.scrollLeft);
            background-color: #E6ECF0;
        }
div#div-gridview {}{
width: 100%;
height: 160px;
overflow: auto;
}

div#div-gridview1
{}{
    width: 420px;
height: 200px;
overflow: auto;
}

div#div-gridview2
{}{
    width: 420px;
height: 200px;
overflow: auto;
}

div#div-gridview3
{}{
height: 0px;
overflow: auto;
}
.fixed  
  {
background-color:White;
      position:   relative     ;  
      top:expression(this.offsetParent.scrollTop);  
      left:expression(this.offsetParent.scrollLeft);  
      z-index:2;  
  }

</style>



</head>

还有这里加调用:
<asp:GridView ID="GridView1" Width="1200px" runat="server" CellPadding="4"
                    ForeColor="#333333" AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" HorizontalAlign="Center" BorderStyle="Groove">
                   
<Columns>
<asp:BoundField DataField="GPRS" HeaderText="GPRS" HtmlEncode="False" >
                            <ItemStyle Height="30px" Width="50px" />
                            </asp:BoundField>
......
</Columns>

<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="fixed" />
                       
</asp:GridView>

注意:在GridView设置总表的宽和高,然后在每列设置高宽,就可以了.前提条件GridView的宽和高,必须大于每列设置高宽之和

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值