gridview 选择行的问题
我在一个gridview在一个div中,div有纵向的滚动条。现在的问题是拖动滚动条选择下面的一条记录后,滚动条会自动到最上方。怎么实现选择后滚动条不变化的效果,先谢谢大家了。 --------------------编程问答-------------------- 不刷新页面也不行? --------------------编程问答-------------------- 支持楼上,大概选中的过程中有刷新。 --------------------编程问答-------------------- 参考看看http://topic.csdn.net/u/20101110/21/59c56f1b-2052-4b24-9f92-4a0e13e598b8.html --------------------编程问答-------------------- 嗯 不回传 --------------------编程问答-------------------- --------------------编程问答-------------------- 可以设置div里面的一个style把
设置它的 overflow: auto;应该可以吧! --------------------编程问答--------------------
在load事件里面加上 if(!Page.IsPostBack),楼主尝试下--------------------编程问答-------------------- 参考看看
http://topic.csdn.net/u/20101110/21/59c56f1b-2052-4b24-9f92-4a0e13e598b8.html
--------------------编程问答-------------------- gridview放在updatepanel里 --------------------编程问答-------------------- gridview本来就在updatepanel里,上面说的方法都不行啊。 --------------------编程问答-------------------- 其实也就是要记录滚动条的位置,在每次加载的时候恢复到原位置。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script type="text/javascript">
function divScroll(){ //记录位置
var scrollPosition=document.getElementById('<%=hdnScrollPosition.ClientID%>');
if (scrollPosition) {
scrollPosition.value = document.getElementById("divContainer").scrollTop;
}
}
function renewScrollPosition(){ //恢复
var scrollPosition=document.getElementById('<%=hdnScrollPosition.ClientID%>');
document.getElementById("divContainer").scrollTop = scrollPosition.value;
}
</script>
</head>
<body onload="renewScrollPosition()">
<form id="form1" runat="server">
<div id="divContainer" style="height:100px;width:300px; overflow:scroll;" onscroll="divScroll()">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
<asp:Button ID="Button1" runat="server" Text="PostBack"
onclick="Button1_Click" />
<asp:HiddenField ID="hdnScrollPosition" runat="server" />
</form>
</body>
</html>
--------------------编程问答-------------------- 隐藏滚动条
用JS
//竖条
<body style="overflow:scroll;overflow-y:hidden">
</body>
//横条
<body style="overflow:scroll;overflow-x:hidden">
</body>
两个都去掉
<body scroll="no">
</body>
CSS
<style>body{overflow-y:hidden;}</style>
补充:.NET技术 , ASP.NET