Nevin Mathai
Nevin Mathai

Reputation: 2396

How to create a Scroll in GridView using ASP.NET

How do I create a scroll in GridView using ASP.NET without using fixed sized div's around it like shown here http://www.aspnettutorials.com/tutorials/controls/gridviewscroll-aspnet2-csharp.aspx .

Upvotes: 2

Views: 5944

Answers (2)

womp
womp

Reputation: 116977

In order to get a scroll bar, you need a fixed height container with overflow set to scroll.

Whether you do it with the grid's properties, like in the example you linked, or by just wrapping it in a Panel with a height and overflow set on it, it doesn't matter much. The key thing is just to get it inside a fixed height container. How you want the UI to look (where the scrollbar is, etc.) will dictate where you create the div.

Upvotes: 0

jball
jball

Reputation: 25014

You can set the div's width or height to a percentage as well, and with overflow:auto, the div contents will scroll if the browser is sized to less than the content.

Without any size settings, your div will simply expand to hold all content, so a percentage, fixed, or inherited size in at least one dimension is required for scrolling to ever occur.

Upvotes: 4

Related Questions