2013-07-10 52 views
0

我有一个比我的aspx页面更宽的gridview,所以我需要gridview的标题与水平滚动条一起滚动,但仍然与垂直滚动条一起修复,我如何这是什么成绩?请帮忙?经过大量的谷歌搜索之后,我在将网格放置在一个div窗格中之后,尝试了各种CSS类,但是这会同时锁定标题和水平和垂直两种方式。请帮助我只修复垂直滚动页眉。我的aspx页面的只在垂直滚动条上冻结gridview标题

部分

<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'); 
} 
+0

你可以显示你的HTML和CSS? – bot

+0

感谢您停止机器人。我已经添加了相关代码,对此的任何帮助都会很棒! – Viniez

回答

0

position:fixed;属性将基于浏览器上的固定部件就位。

+0

但div的位置必须是相对于浏览器,如果浏览器的大小减少,它不能正常工作,如果我保持位置固定!此外,它并没有解决的基本问题,我需要冻结只在垂直滚动头,并保持它在水平滚动移动! – Viniez

+0

是否有任何标准的做法?我认为这是网格视图的一个非常基本的需求!请帮助..我确定有人会实施这个! – Viniez

+0

@Viniez我从来没有真正使用过固定的位置,所以除了告诉你它存在以外,我不能再进一步。 –