如何给GridView添加滚动条 收藏
第一种方法
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
<div style="overflow-y: scroll; height: 200px">
<asp:GridView ID="GridView1" runat="server" Font-Size="12px" BackColor="#FFFFFF"
GridLines="Both" CellPadding="4" Width="560">
<HeaderStyle BackColor="#EDEDED" Height="26px" />
</asp:GridView>
</div>
第二种方法
将Gridview放到一个div里面,设置div的style= "overflow: auto; "
再加CSS (样式表)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
.DataGridFixedHeader
{
POSITION: relative ;
TOP: expression(this.offsetParent.scrollTop);
BACKGROUND-COLOR: blue ;
height:25px;
color:#ffffff;
text-align:center ;
vertical-align:middle;
font-weight:bold;
font-size:13px;
background-color:#5D7B9D;
}
设置Gridview的 HeaderStyle的CSSClass= "DataGridFixedHeader "
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wangjrong/archive/2009/09/15/4553563.aspx