ASP.NET Webforms Gridview width expanding outside container

Home » Client Side Programming » Web Development » ASP.NET Webforms Gridview width expanding outside container
ASP.NET Web forms Logo

Do you have an ASP.NET Webforms application with the GridView expanding outside of its container? Your markup might look like this:

Because the GridView uses a table, sometimes the width of it might expand to larger than your browser window. This might be fine (you could use the scroll bar at the bottom of the browser window), but it also might also cause a problem for example if you have the default widths (width: 100%) in your CSS. You could end up with with the inner part of the GridView extending off the right of the page.

When I originally had this problem I didn’t find a good fix by Googling. The fix is quite simple. Put a CssClass=”results” on the ResultsPanel (the outer div) and define the following CSS:

This will put a scroll bar on the bottom of the GridView.

About Phil

I have been working as a software developer since 1983. This blog could have been called "From Fortran 77, C and Cobol to C# in 20 (not so) easy years", but it doesn't sound quite right somehow. Besides I'm talking about what's happened since 2003, not before!

Leave a Reply

Your email address will not be published.


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">




Top Posts & Pages

Categories

Recent Posts

Recent Comments

Archives

Blogroll

  • Mike Cohn's Blog
  • Scott Hanselman's Blog
- mike@mountaingoatsoftware.com

Being a great product owner is hard. Here are the things your team wants from you to help them do th [...]

- mike@mountaingoatsoftware.com

Want to learn about Kanban? Here’s a complete guide to introducing Kanban into your organization. [...]

- mike@mountaingoatsoftware.com

Lack of communication is a common problem that causes delays, rework, or adds risk. See how Kanban “ [...]

- mike@mountaingoatsoftware.com

It’s easy to say you limit how much work you’ll have in process. It’s harder to live up to it, espec [...]

- mike@mountaingoatsoftware.com

You told me you have questions about Kanban. Here are some answers from Kanban expert, Brendan Wovch [...]

- Scott Hanselman

I love my Nintendo Switch. It's a brilliant console that fits into my lifestyle. I use it on pl [...]

- Scott Hanselman

I was fortunate to be a guest on Steve Carroll's talk show "Careers Behind the Code," [...]

- Scott Hanselman

I've been talking about it for months, but in case you haven't heard, there's a new W [...]

- Scott Hanselman

I posted recently about What's the difference between a console, a terminal, and a shell? The w [...]

- Scott Hanselman

Earlier this week I announced over 80 new free videos in our .NET Core 3.0 launch video series - Ann [...]

Meta