由于您已经为此使用了一个插件,相信您使用另一个插件应该不难,但这次它应该使您的标题宽度与您的数据列对齐。确保使用ItemStyle-Width 属性为boundcolumn 或TemplateField 定义/调整列宽
链接到 GridViewScroll Demo 可以完美地完成这项工作。从here 下载插件。
对于类似的问题,请参考我在 SO 上的其他答案 here 和 here
这里是代码
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="gridviewScroll.min.js"></script>
<link href="GridviewScroll.css" rel="stylesheet" />
function pageLoad(sender, args) {
gridviewScroll ();
}
function gridviewScroll() {
gridView1 = $('#GridView1').gridviewScroll({
width: 915,
height: 449,
railcolor: "#F0F0F0",
barcolor: "#CDCDCD",
barhovercolor: "#606060",
bgcolor: "#F0F0F0",
freezesize: 5,
arrowsize: 30,
varrowtopimg: "../../../images/arrowvt.png",
varrowbottomimg: "../../../images/arrowvb.png",
harrowleftimg: "../../../images/arrowhl.png",
harrowrightimg: "../../../images/arrowhr.png",
headerrowcount: 1,
onScrollVertical: function (delta) {
// store the scroll offset outside of this function in a hidden field and restore if you want to maintain vertical scroll position
},
onScrollHorizontal: function (delta) {
//store the scroll offset outside of this function in a hidden field and restore if you want to maintain horizontal scroll position
}
});
}