views:

1668

answers:

2

I have an ASP.Net GridView control that I need to remain a fixed size whether there are 0 records or n records in the grid. The header and the footer should remain in the same position regardless of the amount of data in the grid. Obviously, I need to implement paging for larger datasets but how would I achieve this fixed sized GridView? Ideally I would like this to be a reusable control.

+1  A: 

You may have to drop the headers and footers from the GridView altogether and add them to the page as separate table elements. You will need to make sure each table cell in the header and footer tables have fixed widths that correspond to the widths of the cells in your GridView.

The GridView itself would probably be nested in a DIV tag of a fixed height. Something like as follows.

<table><tr><td style="width:100px">Header 1</td><td style="width:200px">Header 2</td></table>
<div style="width:300px;height:400px">
<asp:GridView>.....</asp:GridView>
</div>
<table><tr><td style="width:100px">Footer 1</td><td style="width:200px">Footer 2</td></table>

You will probably have to tweak the margin and padding value to get it all to line up exactly though.

Tim C
A: 

Check this link

YordanGeorgiev