Home ProgrammingASP.NET GridView with Scrollbars

GridView with Scrollbars

by John Bhatt
765 views

Hi,

Today I am here to share something to you. This is simpler as never but I bet, you are searching for this since long.

GridView with Scrollbars

If you have developed any web application using ASP.NET, you must have used GridView, if you are beginner and learning ASP.NET, this will tell you how to make display GridView with Scrollbars. As we know, we can Paginate data in GridView, but putting a Scrollbar is really confusing as it is not in default properties of GridView control.

Lets design a web form and insert a GridView. I am using no designs and just a form and dragged and auto formatted GridView control in this tutorial.

GridView with Scrollbars

Lets see the code for this web form.
[html]

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="” SelectCommand=”SELECT * FROM [Districts]”>

[/html]
I have bind data from one of my projects, this is schema of Address and table is District List. Lets run the Web form, our output is:

GridView with Scrollbars
This is how it will list record and entire page will have GridView data. To fix this, I have added just a style tag to Div and some code inside that tag. Below is code.
[css]
..style=”height:400px; overflow:auto”..
//You can change overflow:auto to overflow:scroll but that will show both Scrollbar and always. Above will show Vertical Scrollbar only when the Height of GridView exceeds than assigned height.[/css]
After adding above code, I refreshed the browser, Now this is the new and required layout of GridView with Scrollbars.
You can download the source code from JohnBhatt.com for free.
Enjoy. Till then subscribe our feeds and get updated. You can also drop a comment below to suggest us improving.

You may also like

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

GridView with Scrollbars

by John Bhatt time to read: 1 min
0