Set Gridview height to Percentage of Screen Height

AlHal2
AlHal2 used Ask the Experts™
on
I'm using ASP.net.
Is it possible to Set the Gridview height to Percentage of Screen Height rather than an absolute number of pixels?
Width seems to allow this.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Karrtik IyerSoftware Architect

Commented:
I am aware that by setting the dock property, it allows the grid to be same size of the parent (form/user control)
myGridView.Dock = DockStyle.Fill;// This can also be set to left, or right, etc..

Does this help you?
AndyAinscowFreelance programmer / Consultant

Commented:
I don't think so - because it can grow/shrink vertically based on the number of rows should the contents be modified dynamically.
Karrtik IyerSoftware Architect

Commented:
In Asp.NET I was able to do the below, does this work for you? It sets as percentage of the of the parent form.
  <asp:GridView  ID="GridView1" runat="server" Width="50%" Height ="50%">
            
        </asp:GridView>

Open in new window

C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Author

Commented:
I tried that.  When the grid had lots of rows it just passed the bottom of the screen.  I'd set it to be 20% of the screen height with verticals scrollbars.

<asp:GridView ID="GridView1" runat="server" DataKeyNames ="xxx"  
        AllowSorting="True" Font-Names="Arial" Font-Size="Small"  
        RowStyle-Wrap="False" BackColor="White" BorderColor="Silver"    
        AutoGenerateColumns="True" onsorting="GridView1_Sorting" Height="20%" Width ="80%">
           
            <RowStyle Wrap="False" />  
             
    </asp:GridView>
Freelance programmer / Consultant
Commented:
What if you put the gridview inside another section and try to control the height of that section.
eg.
http://stackoverflow.com/questions/17562118/asp-net-gridview-within-scrollable-div-scroll-to-selectedindex

Author

Commented:
Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial