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
sqdperuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul JacksonSoftware EngineerCommented:
You can use the pagesize attribute of the gridview to control the maximum number of rows to show but you also need to set the paging attribute to true.


            <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"; Pagesize=10; Paging=true;>
            </asp:GridView>

Do you have the gridview in a DIV container ?  Generally you would put a Gridview in a DIV container and set a maximum height and width to the DIV will stop the containing controls from expanding on the page beyond the limits of the DIV.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sqdperuAuthor Commented:
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
0
sqdperuAuthor Commented:
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
1
sqdperuAuthor Commented:
Thanks Paul for heading me down the correct path.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.