2010-11-06 80 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的頂部,列名

不要忘了固定列的大小,讓他們在同一作爲頂部的列名稱。