Link to home
Create AccountLog in
Avatar of sqdperu
sqdperuFlag 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

User generated image---------------------------------------------------------------------------------------------------------------------------------------------------------
User generated image
ASKER CERTIFIED SOLUTION
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of 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
Avatar of 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>

User generated image
Avatar of sqdperu

ASKER

Thanks Paul for heading me down the correct path.