ASP GUIDVIEW 固定首行

 

1、首先,在.aspx文件中加入CSS设定:

<style type="text/css">

.FixedTitleRow     
{     
    position: relative;      
    table-layout:fixed;  
    top: expression(this.offsetParent.scrollTop-2);  
    background-color:White;  
    z-index: 10;     
}     
  
.FixedTitleRow th  
{  
    text-overflow:ellipsis;  
    overflow:hidden;  
    white-space: nowrap;  
    padding:2px;  
}  
     
.FixedTitleColumn     
{     
    position: relative;      
    left: expression(this.parentElement.offsetParent.scrollLeft-2);     
}     
     
.FixedDataColumn     
{     
    position: relative;     
    left: expression(this.parentElement.offsetParent.offsetParent.scrollLeft-2);     
}   

</style>
2、去掉:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

 
3、为gridview表头设置样式(锁定表头):在.cs文件中的load方法中设置即可

GridView1.HeaderStyle.CssClass="FixedTitleRow";

4、若固定左边的一列,设定HeaderStyle的CssClass=FixedTitleColumn,以及ItemStyle的CssClass=FixedDataColumn。即可

posted on 2017-07-30 13:04  所有人都  阅读(162)  评论(0)    收藏  举报

导航