给gridview设置滚动条有很多方式.
最简单的是将gridview放到一个panel中,然后给panel加上 ScrollBars="Vertical" 属性,便可以实现,但是这样标题头会随着滚动。
从一个网名为小小鸟的人那里学到如何给gridview 添加纵向滚动条,标题头不滚动 。首先定义一个样式表:
<style>
.Freezing
{
position:relative ;
table-layout:fixed;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}
.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}
</style>
Freezing 应用在HeaderStyle中,把gridview放置在div中,且将该div设置样式 style="overflow-y: scroll;“