Avatar of sqdperu
sqdperu
Flag for United States of America asked on

ASP.NET Web Forms / VB.NET app, how do you prevent GridView from expanding?

This is my first attempt to create a "ASP.NET Web Forms application".  I am using VB.NET as the language.

I am having trouble getting the GridView control to stay the same size instead of expanding when there are more than 3 or 4 rows.   I want it to always stay the same size on the page as I am going to add more to the page under it and don't want it to expand over the top of those items.

Things I have tried:
- setting the Height property of the GridView to 140px
- Added "; overflow:auto" Height="140px"" as shown in code below to get vertical scroll bars and to and limit height. (neither which appear to have any effect)
            <asp:GridView ID="grdDrawings" runat="server" BackColor="#CCCCCC" Font-Names="Arial" Font-Size="Small" style="top: 61px; left: 8px; position: absolute; height: 73px; width: 1047px; overflow:auto" Height="140px">
            </asp:GridView>

Open in new window


See the attached files for what my design view looks like and the actual results when I do run it.

NOTE: Please provide a solution that use VB.NET code if at all possible.  
Thanks

Design.JPG---------------------------------------------------------------------------------------------------------------------------------------------------------
Results.JPG
ASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
sqdperu

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Paul Jackson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
sqdperu

ASKER
Thanks Paul,

I don't want to limit the number of rows that can be displayed, just the space that it can take up and use vertical scroll bar to view all the records in that space.
I'm new to the ASP.NET and how it works with the VB.NET.  I didn't know about the need for the DIV.
I added the DIV and put my GridView in it, but it still expand out larger.   What did I do wrong?  Here is the ASP as it looks now:
           <div style="width: 1076px; top: 63px; left: 7px; position: absolute; height: 122px">
            <asp:GridView ID="grdDrawings" runat="server" BackColor="#CCCCCC" Font-Names="Arial" Font-Size="Small" style="top: 4px; left: 1px; position: absolute; height: 73px; width: 1065px; overflow:auto" Height="120px">
            </asp:GridView>
            </div>

Open in new window


Thanks
sqdperu

ASKER
I ended up getting it to work by adding the DIV around the GridView and moving the "overflow:auto" ASP.NET code out of the GridView and into the the DIV.   It is now contained to a limited space and I have scroll bars.  Thanks Paul heading me down the correct path.

Here is the code now that worked for me:

        <div style="width: 1141px; top: 63px; left: 7px; position: absolute; height: 122px; overflow:auto">
            <asp:GridView ID="grdDrawings" runat="server" BackColor="#CCCCCC" Font-Names="Arial" Font-Size="Small" style="top: 4px; left: 1px; position: absolute; height: 73px; width: 1135px" Height="120px">
            </asp:GridView>
            </div>

NewResults.JPG
sqdperu

ASKER
Thanks Paul for heading me down the correct path.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck