BUG: ScrollableGrid Control
Someone (thanks, David) pointed out a bug in my ScrollableGrid control from the January 2004 issue of aspnetPRO magazine. The control adds a frozen header and footer to a grid and makes the body of it scrollable using the overflow CSS attribute of recent browsers.
If the data source contains less rows than can fit into the fixed-height grid, then the actual height of each row is calculated proportionally. In other words, if you going to have a 100 pixel grid with only two rows to display, each row takes 50 pixels. Which obviously results in a bad looking grid.
The simplest workaround--at this time I'm not even sure a perfect workaround does exist--consists in overriding the DataGrid's Height property as follows:
public override Unit Height
{
get {return (Unit) ViewState["TableHeight"];}
set {ViewState["TableHeight"] = value;}
}
Just add this code to mydatagrid.cs and recompile. It works now but it's not perfect. The scrollbar is not displayed and its reserved space is left blank. Not too bad, but not perfect either.
You might want to modify the settings for the overflow style too and replace overflow:auto with overflow:scroll throughout the code of the mydatagrid.cs file. In this case, the scrollbars (both horz and vert) are always displayed, disabled if necessary.
You can't just know in a piece of server-side code about the client settings of the scrollbars. IE6 returns that info but you can access it only using DHTML.