Skip to content Skip to sidebar Skip to footer

Gridview Freeze Pane Header Not Freezing After Page Loads

Browser - IE 9 Using the Latest Version of Microsoft's AdventureWorks2012 sandbox database (AdventureWorks2012_Data.zip) for SQL related Data. I had to put this project on the back

Solution 1:

You are almost there. You should name the javascript function Onscrollfnction().

EDIT:

  1. You replace the HeaderDiv content with tr html.
  2. You have to apply style to HeaderDiv.

Here's the script:

</style><scriptsrc="//code.jquery.com/jquery-1.10.2.js"></script><scripttype="text/javascript">functionOnscrollfnction() {
        var header = $("#GridView1").find('tr:first').html();
        $("#HeaderDiv").html(header);
        $("#HeaderDiv").addClass("GridViewHeaderStyle");
    }
</script>

Further improvements:

  1. I would apply fixed width to GridView Columns and apply the widths to headers in the HeaderDiv column headers.

  2. I would hide the GridView's header and display the HeaderDiv instead, to avoid the annoying transition in the beginning of scrolling.

Solution 2:

I got frustruated with trying to find a javascript solution so I found one that is CSS based and works perfectly. For anyone who needs it moving forward, here's the article I referenced.

Scrollable GridView With Fixed Headers Asp.Net

Post a Comment for "Gridview Freeze Pane Header Not Freezing After Page Loads"