Link to home
Create AccountLog in
Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Set Gridview height to Percentage of Screen Height

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.
Avatar of Karrtik Iyer
Karrtik Iyer
Flag of India image

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?
Avatar of AndyAinscow
I don't think so - because it can grow/shrink vertically based on the number of rows should the contents be modified dynamically.
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

Avatar of AlHal2

ASKER

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>
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of AlHal2

ASKER

Thanks.