ASP.NET_搭配javascript 實踐表頭靜止而資料列滾動

這次要分享的技巧是如何固定表頭只保留下方資料列(當資料量多會很多列時候) 避免讓使用者往下滾表頭不見操作起來不開心 程式碼 Head部分的Js 跟body部分的GridView 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 <head runat= "server" > <meta http-equiv= "Content-Type" content= "text/html;charset=big5" /> <title></title> <script type= "text/javascript" > function DoAutoScrollAdujst () { var gv = document.getElementById( "<%= GvLeaveRecords.ClientID%>" ) ; var gvTmp = gv.cloneNode( true ) ; for (idx = gvTmp.rows.length - 1 ; idx > 0 ; idx -- ) { gvTmp.deleteRow(idx) ; } gv.deleteRow( 0 ) ; GvHeader.appendChild(gvTmp) ; } window.onload = DoAutoScrollAdujst ...