I have a grid view, the problem I am facing is when there is only 1 row in the table the header and the only row is really big, when the number of rows increases then the size of whole table and the header shrinks and it looks good, when there is few records it is looks like this
!http://www.freeimagehosting.net/43572
What is the problem here. thanks
<asp:GridView ID="Grid_Messagetable" runat="server" BorderStyle="Ridge" BorderWidth="5"
CssClass="Grid_MsgTbl" CellPadding="1" CellSpacing="1" AllowPaging="False" SelectedIndex="0"
DataKeyNames="MsgID" ShowHeaderWhenEmpty="false" OnRowDeleting="Grid_Messagetable_RowDeleting"
OnRowDataBound="MyGrid_RowDataBound" AutoGenerateColumns="False" AllowSorting="true"
OnSorting="gridView_Sorting">
.Grid_MsgTbl
{
text-align: center;
z-index: 1;
left: 7px;
top: 5px;
position: relative;
height: 308px;
width: 646px;
right: 17px;
bottom: 524px;
}
I think you need to add more styles to your
css.Add
<HeaderStyle Height="30px"/>Also add
AlternatingRowStyle-CssClass="altrowstyle" and HeaderStyle-CssClass="headerstyle"so you can add something like this to your
cssBut setting the height for the
gridviewnot a good way of doing it since.netis clever enough to adjest the height accoding to data.Anyway I think this article about ASP.NET GridView makeover using CSS will give you better idea.
Hope this helps