2013-07-10 53 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我從來沒有真正使用過固定的位置,所以除了告訴你它存在以外,我不能再進一步。 –