See this thread
but a 1000 rows is too many. You should use a JavaScript table with virtual scrolling. See the popular datatables
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am developing ASP.NET application.
I have been using gridview for adding/editing/deleting records for most of the forms.
some of the gridview will have more than 1000 rows.
for temporary, i have used CSS overflow to freeze the records.
But, it will scroll the entire gridview (including header and rows.)
I want to freeze the gridview header column and then rows like excel freeze.
How to do this..? Is there any way to freeze gridview header except css overflow..?
See this thread
but a 1000 rows is too many. You should use a JavaScript table with virtual scrolling. See the popular datatables
Hi @BeUnique,
You can use jQuery DataTable plugin to fix the header.
Demo:
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/fixedcolumns/4.1.0/js/dataTables.fixedColumns.min.js"></script>
<link href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.datatables.net/fixedcolumns/4.1.0/css/fixedColumns.dataTables.min.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.auto-style1 { width: 600px; border-style: solid; border-width: 2px; }
.dataTables_scrollHead { width: 600px !important; }
.dataTables_scrollHeadInner { width: 600px !important; }
.dataTables_scrollBody { width: 600px !important; }
</style>
<script type="text/javascript">
$(function () {
$('#gvCustomers tfoot tr').appendTo('#gvCustomers thead');
$('#gvCustomers').removeAttr('width').DataTable({
bFilter: true,
bSort: true,
scrollY: "150px",
scrollCollapse: true,
paging: false,
fixedColumns: false,
orderCellsTop: true
});
});
</script>
Or use Responsive used with the DataTables FixedHeader extension.
https://datatables.net/extensions/responsive/examples/column-control/fixedHeader.html
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread
I tried below, and it worked for me. Please try out