2010-11-06 55 views
0

我有一个网格视图放置在一个div和滚动条在那里。我想将网格视图标题设置为固定,并且只滚动内容将可滚动。 如何做到这一点.... 在此先感谢....在asp.net中使用可滚动主体的固定标题Gridview

+0

我认为有人问过这个已经:http://stackoverflow.com/questions/157528/how-to-freeze-gridview-header – Moonshield 2010-11-06 10:18:21

回答

1

在C# GVBrand.HeaderRow.TableSection = TableRowSection.TableHeader;在GridView控件

附加follwoing CSS

table { 
     width: 100%; 
    } 

    thead, tbody, tr, td, th { display: block; } 

    tr:after { 
     content: ' '; 
     display: block; 
     visibility: hidden; 
     clear: both; 
    } 

    thead th { 
     height: 30px; 

     /*text-align: left;*/ 
    } 

    tbody { 
     height: 120px; 
     overflow-y: auto; 
    } 

    thead { 
     /* fallback */ 
    } 


    tbody td, thead th { 
     width: 19.2%; 
     float: left; 
    } 

http://jsfiddle.net/T9Bhm/7/

1

请尝试执行以下操作。

隐藏标题 配置DIV,让你拥有侧栏 添加在DIV另一个DIV的顶部,列名

不要忘了固定列的大小,让他们在同一作为顶部的列名称。