How to set height/width of Gridview and Panel control?

  • Thread starter Thread starter JB
  • Start date Start date
J

JB

Hello

I am using ASP.Net web page (C# codebehind with javascript) that
contains an <asp:GridView> control which should have height = 50px and the
width = 1150px. This <asp:GridView> resides inside of an <asp:Panel>
control which should also be height=50px and width=1150px. It looks like
this on the web page source code:

<table id="Pscont">
<tr>
<td>
<asp:Panel ID="Pspan" runat="server">
<asp:GridView ID="PsGrid" Width="1150px" Height="50px"
runat="server">
</asp:GridView>
</asp:Panel>
</td>
</tr>
</table>

The codebehind looks like this:
if (!Page.IsPostBack)
{
//Pspan.Height = new Unit("50px");
GetData fillGrid = new GetData();
PsGrid.DataSource = fillGrid.loadGrid();
PsGrid.DataBind();
}

I even have a CSS file that contains this:
#PsGrid
{
position:absolute;
top:325px;
left:13px;
height:auto;
}

However none of these works the GridView spreads all over the whole web page
to the bottom of the page. How can I make the GridView comform to the size
that I am setting it to?
 
JB said:
I am using ASP.Net web page (C# codebehind with javascript) that
contains an <asp:GridView> control which should have height = 50px and the
width = 1150px. This <asp:GridView> resides inside of an <asp:Panel>
control which should also be height=50px and width=1150px. It looks like
this on the web page source code:

<table id="Pscont">
<tr>
<td>
<asp:Panel ID="Pspan" runat="server">
<asp:GridView ID="PsGrid" Width="1150px" Height="50px"
runat="server">
</asp:GridView>
</asp:Panel>
</td>
</tr>
</table>

The codebehind looks like this:
if (!Page.IsPostBack)
{
//Pspan.Height = new Unit("50px");
GetData fillGrid = new GetData();
PsGrid.DataSource = fillGrid.loadGrid();
PsGrid.DataBind();
}

I even have a CSS file that contains this:
#PsGrid
{
position:absolute;
top:325px;
left:13px;
height:auto;
}

However none of these works the GridView spreads all over the whole web page
to the bottom of the page. How can I make the GridView comform to the size
that I am setting it to?

You should be able to wrap it inside a <div> with max-height.
 
Back
Top