问题
I have an asp.NET grid listing with unlimited columns and rows. This is showing as a result of search (some kind of work history data). Depending on the search criteria, the no. of columns and no. of rows will increase.
I need to fix/freeze first row (header portion) and 3 columns on the left (that 3 columns need to show all the time and rest of the contents can scroll).
In the code page this much content is visible:
<div style="height:500px; overflow:auto">
<asp:GridView ID="someid" runat="server">
</asp:GridView>
</div>

The header columns are dynamically coming and 'n' no. of heading will come (like April 2016, May 1026 and so on..), so cannot apply 'id' for each heading. also the same for the first 3 left columns. Any solution for this?
回答1:
Take a look at this gridviewscroll pluggin, here you find a jquery pluggin to accomplish what you want
and after you add the proper css
and js
files the code you should use is this:
$(document).ready(function () {
gridviewScroll();
});
function gridviewScroll() {
$('#<%=someid.ClientID%>').gridviewScroll({
width: 660, //change this two values by
height: 200, //your real width and height
freezesize: 3
});
}
来源:https://stackoverflow.com/questions/30400019/how-to-freeze-header-and-first-column-of-a-table-data-grid-listing-with-unlimite