Lock the gridview pager in place while scrolling up and down

I am working with a gridview that requires both paging and horizontal/vertical scrolling while keeping the navigation bar at the bottom of the page.

When scrolling vertically, I need two things:

  1. The gridview headers should stay frozen.
  2. The gridview pagers should also remain frozen.

This means they should not scroll along with the data - only the rows should scroll.

So far, I have achieved:

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<style type="text/css">
    div#gvResultStyle
    {
        width: 500px;
        height: 350px;
        overflow: scroll;
        position: relative;
    }

    div#gvResultStyle th
    {
        background-color: Navy;
        color: White;
        top: expression(document.getElementById("gvResultStyle").scrollTop-2);
        left: expression(parentNode.scrollLeft);
        position: relative;
        z-index: 20;
    }

    .gvPager
    {
        left: 0px;
        width: 400px;
        border-right-style: solid;
        position: absolute;
        height: 10px;
        text-align: left;
        border-right-color: Navy;
    }
</style>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
    Welcome to ASP.NET!
</h2>
<p>
    To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">
        www.asp.net</a>.
</p>
<p>
    You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
        title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
</p>
<div id="gvResultStyle">
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"
    DataSourceID="SqlDataSource1" AllowPaging="true" PageSize="20" CssClass="gvResultStyle">
    <PagerSettings Position="Bottom" />
    <PagerStyle CssClass="gvPager" />
    <Columns>
        <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
            ReadOnly="True" SortExpression="ProductID" />
        <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
        <asp:BoundField DataField="SupplierID" HeaderText="SupplierID" SortExpression="SupplierID" />
        <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />
        <asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" />
        <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
        <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
        <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
        <asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" SortExpression="ReorderLevel" />
        <asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" />
        <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
    </Columns>
</asp:GridView>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT * FROM [Alphabetical list of products]"></asp:SqlDataSource>
<br />

Answer №1

I have developed a jQuery plugin that can lock headers and freeze columns, perfect for use with GridView components. Check out the screenshot below:

The functionality also includes support for pagination:

See a demonstration here: Pager Support

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The feature to navigate to a different section on another page is experiencing a malfunction

I'm facing an issue with my navbar setup: <ul class="dropdown-menu" role="menu"> <li><a href="/main_page#top_something">People</a></li> <li><a href="/main_page"&g ...

Content in Table TD with rowspan attribute is concealed by setting the visibility of TR to "collapse"

I have created an HTML table where some rows are hidden using CSS with visibility:collapse By default, only the first and last rows of the table are visible. In one column on the right side, I've set rowspan to accommodate multiple lines of text. T ...

What determines the padding of a display:table-cell?

I am currently working on creating a table-like layout where medicine names will be displayed on the left and data will occupy the rest of the table. In simpler terms: +-------------+------------+ medicine 1 | some data | some data | ...

Can anyone provide instructions on how to create a theme change animation using Vuetify?

Follow these steps to understand what I'm describing: Go to the Vuetify website Click on the settings icon Choose between the dark or light theme option. When you switch between themes, there is an animation that occurs. A circle starts expanding fr ...

Display a different image while another image is in the process of loading

I am currently facing an issue with a div that has a background image set up as follows: <div class="carousel-image" style="background: url(img/background.gif) no-repeat center center;"> </div> Upon loading my webpage, there is a brief ...

I am interested in creating a design where two DIVs are layered on top of each other with one having transparency, allowing visibility through to the background DIV. This can be achieved using a combination of

Looking to enhance the visual appeal of my website, I decided to incorporate a background image within a div. To add more depth and creativity, I am now striving to overlay a semi-transparent black box on top of the image. This overlay will not only allo ...

Is it possible to utilize formatted strings in Python selenium to locate elements based on different categories such as xpath, css, etc?

An interesting revelation just hit me and it's quite unsettling since my entire program relies on locating elements by CSS selector using formatted strings. Let's consider this example: stop_iteration_for_foh = driver.find_element_by_css_selecto ...

Troubleshooting: Unable to get CSS selector to work with Bootstrap popover

I am facing an issue in my CSS file where I need to target the ul tag inside a popover. I attempted to do this by using the code .myClass ul {list-style: none;}, but unfortunately, it did not work as expected. When I tried using .popover ul {...}, it did w ...

I am in search of sample cases demonstrating the process of incorporating a throbber while pages are

Is there anyone who can provide a code snippet demonstrating how to implement an animated throbber during the loading of an asp.net page? I would greatly appreciate multiple examples if possible. ...

Resize the div based on the width and height of the window

My goal is to create a system or website that can be fully resizable using CSS and the VW (viewport width) unit. Within this system, I have integrated a GoogleChart that functions with pixels. Now, I am looking for a way to scale the chart using Javascript ...

Implement Identity features once your MVC website has been established in Visual Studio 2015

When setting up an MVC website in VS2015, I have the option to select Individual Identity, which includes all the Account features like Login, logout, [Authorize] and more. However, if I initially created a new project without Authentication and later dec ...

Utilizing Clickatell for Sending SMS in ASP.Net

I attempted to run this code found on their website using System.Net; using System.IO; WebClient client = new WebClient(); // Add a user agent header in case the requested URI contains a query. client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MS ...

Conceal the property identifier within the error message for Data Annotation validation

Recently, I've been working with an asp.net core model that looks like this: public class MyModel { [ModelBinder(Name = "id")] [StringLength(36, MinimumLength = 3)] public string ObjectId { get; set; } } In order to rename the field "Obj ...

Guide on how to turn off a checkbox "toggle switch" using JavaScript

Being relatively new to CSS and HTML, I recently experimented with creating a checkbox toggle switch using this resource. I now have a specific requirement to disable this toggle switch upon clicking a different button labeled 'Reset', making it ...

Prevent IonContent from scrolling to the bottom or top when using Ionic framework

In my Ionic app, I have a long text page with 2 buttons that trigger the actions scrollToBottom and scrollToTop. Due to the length of the page, I have set the scroll duration to be 30 seconds. I am facing two issues here: How can I stop the scrolling ...

Navigating back to the previous page URL using ASP.NET Core with MVC and C#

After conducting some research, I came across suggestions to utilize the following line of code. However, this only retrieves the current URL rather than the previous page's URL. Request.Headers["Referer"].ToString(); I attempted to access the previ ...

The PHP code to include the head section with a link to the CSS is not functioning properly

I've recently dabbled in PHP and encountered my first issue that I can't seem to resolve. My goal is to have my index.php file, with the following code in the head section: <head> <?php require 'php/main/head.html'; ?> & ...

Revealing or Concealing a column with a Checkbox Toggle

Showing and Hiding Columns with Checkbox Selection DISCLAIMER: I have exhausted all available solutions before posting this question, as none of them have worked for me so far. I joined specifically because the existing solutions did not meet my needs. T ...

Ways to focus on TinyMCE editor for customization

Would it be possible to target the entire TinyMCE editor in order to apply some styling, such as adding 10px of padding around it? I'm using TinyMCE 4 and starting with the HTML code shown below results in TinyMCE generating additional HTML. I would ...

Tips for creating an animated effect on the active tab when it switches

Currently, I have a tab list containing li items. When an item is active, the li item has rounded corners and a box shadow effect. My goal is to add an animation that shows the active pill moving to its next position when it changes, but I am unsure of how ...