Freeze Header:
1. Define class .Freezing in Stylesheet:
.Freezing { position:relative ; top:expression(this.offsetParent.scrollTop); z-index: 10; } | ||
<HeaderStyle ... CssClass= "Freezing" ...></HeaderStyle> | ||
3. You are done!
Freeze Columns:
1. Define class .FreezingCol in Stylesheet:
.FreezingCol { LEFT: expression(document.getElementById("freezingDiv").scrollLeft); /*freezingDiv is the name of the div to make your datagrid scrollable */ POSITION: relative; z-index: 1; } | ||
2. Assign Columns' cssClass to FreezingCol
If you have templateColumn, you can simply assign cssClass of the column to freezingCol. If you create the columns dynamically, you can assign the cssClass at runtime within ItemCreated event. For example:
e.Item.Cells(0).CssClass = "FreezingCol" e.Item.Cells(1).CssClass = "FreezingCol" | ||
3. You are done! Please keep in mind this solution only works with IE5 & up. To make cross browser solution, you need to use javascript which is out of scope of this article.
Happy Programming!