静以思

Microsoft .NET[C#] - SQL SERVER - ORACLE - Web Design

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
ASP.NET中GridView 表头不动内容滚动解决法

前台

<script>
function scrool()
{
 var t = document.getElementById("<%=gvCheckList.ClientID%>");
 var t2 = t.cloneNode(true)
 for(i = t2.rows.length -1;i > 0;i--)
 t2.deleteRow(i) 
 t.deleteRow(0) 
 head1.appendChild(t2)
}
window.onload = scrool
</script>

<div id="head1"></div>
 <div style="height:186px;width:100%;overflow-y: scroll;">
<asp:GridView ID="GridView1" runat="server" Width="97%" >
           <RowStyle Height="26px" />
            <HeaderStyle BackColor="#EDEDED" Height="26px" />
</asp:GridView>
 </div>

后台代码
Page_Load

this.GridView1.Attributes.Add("style", "table-layout:fixed");

posted on 2008-02-02 11:32  plife  阅读(2948)  评论(3)    收藏  举报