C# 仅在垂直滚动上冻结gridview标题
我有一个gridview,它比我的aspx页面宽,所以我需要gridview的标题用水平滚动条滚动,但用垂直滚动条保持固定,我如何实现这一点?请帮忙?在谷歌搜索了很多次之后,我在将网格放在div窗格中之后尝试了各种css类,但这会同时锁定标题的水平和垂直方向。请帮助我修复垂直滚动上的标题 我的aspx页面的一部分C# 仅在垂直滚动上冻结gridview标题,c#,asp.net,css,gridview,scroll,C#,Asp.net,Css,Gridview,Scroll,我有一个gridview,它比我的aspx页面宽,所以我需要gridview的标题用水平滚动条滚动,但用垂直滚动条保持固定,我如何实现这一点?请帮忙?在谷歌搜索了很多次之后,我在将网格放在div窗格中之后尝试了各种css类,但这会同时锁定标题的水平和垂直方向。请帮助我修复垂直滚动上的标题 我的aspx页面的一部分 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTrig
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<div runat="server" id="GridViewDiv" style="overflow:auto" >
<asp:HiddenField ID="BindOnPostBack" Value="1" runat="server" />
<asp:GridView Width="100%" ID="ProjectsGridView" runat="server" AutoGenerateColumns="false"
OnRowCreated="BudgetGridView_RowCreated" OnRowDataBound="BudgetGridView_RowDataBound" PagerSettings-Visible="true" PageSize="20"
AllowPaging="true" AllowSorting="true" RowStyle-BackColor="#E8EAF7" RowStyle-BorderColor="White"
RowStyle-Height="19px" RowStyle-Font-Size="11px" RowStyle-HorizontalAlign="Left"
RowStyle-VerticalAlign="Middle" RowStyle-Font-Names="Tahoma,Helvetica,Arial"
HeaderStyle-BackColor="#d1d5ef" HeaderStyle-Height="22px" HeaderStyle-HorizontalAlign="Left"
HeaderStyle-Font-Names="Tahoma,Helvetica,Arial" HeaderStyle-Font-Size="13px"
HeaderStyle-Wrap="false" HeaderStyle-Font-Underline="false" RowStyle-Wrap="false"
PagerSettings-Position="Top" DataKeyNames="ID">
and my css for this:
div#GridViewDiv {
width: expression(document.getElementById("ctl00_contentPanel").style.width);
height: expression(document.getElementById("contentdiv").style.width);
overflow: scroll;
position: relative;
}
div#GridViewDiv th {
top: expression(document.getElementById("GridViewDiv").scrollTop - 2);
left: expression(parentNode.parentNode.parentNode.parentNode.scrollLeft);
position: relative;
z-index: 50;
}
td.locked, th.locked {
position:relative;
left:expression((this.parentElement.parentElement.parentElement.parentElement.scrollLeft-2)+'px');
}
还有我的css:
div#gridview div{
宽度:表达式(document.getElementById(“ctl00_contentPanel”).style.width);
高度:表达式(document.getElementById(“contentdiv”).style.width);
溢出:滚动;
位置:相对位置;
}
div#gridview div th{
top:表达式(document.getElementById(“GridViewDiv”).scrollTop-2);
左:表达式(parentNode.parentNode.parentNode.parentNode.parentNode.scrollLeft);
位置:相对位置;
z指数:50;
}
td.locked,th.locked{
位置:相对位置;
左:表达式((this.parentElement.parentElement.parentElement.parentElement.scrollLeft-2)+'px');
}
位置:固定代码>属性将根据浏览器将组件修复到位。您能显示html和css吗?感谢您通过bot停止。我已经添加了相关的代码,在这方面的任何帮助都将是巨大的!但是div的位置必须是相对于浏览器的,如果浏览器的大小减小,如果我保持位置不变,它就不能正常工作!此外,它也不能解决基本问题,我需要冻结标题只有在垂直滚动和保持它在水平滚动移动!没有任何标准的方法吗?我认为这是网格视图的基本需求!!!请帮忙。。我肯定会有人实施这个@维尼兹,我从来没有真正使用过固定位置,所以除了告诉你们它的存在,我再也帮不上忙了。