ASP.NET - freeze header - Asked By msakt on 24-May-12 12:49 AM

.GVHeader
{
    height: 25px;
   /*position:absolute;*/
    background-color: #c8d3f2;
    color: #000;
    font-weight: bold;
    overflow:hidden;

}
i am using tis style for gridview header...if use position:absolute...freeze header is work but header width differ from column width...if command position:absolute   width set correctly not working freeze header



Jitendra Faye replied to msakt on 24-May-12 12:56 AM
Simply apply CSS for header style,

<HeaderStyle CssClass="header"Height="20px" />

the css

<style type="text/css">
  .header
  {
    font-weight:bold;
    position:relative;
    background-color:White;
  }
  </style>
Somesh Yadav replied to msakt on 24-May-12 01:28 AM

Option (a) buy into a UI package that includes a souped-up GridView with this functionality built-in.

Option (b) roll your own - it's not simple. Dino Esposito http://weblogs.asp.net/despos/archive/2003/12/12/43091.aspx.

EDIT: Just noticed that the Dino article links to a subscriber-only area on the ASPnetPro magazine site.

Here's http://weblogs.asp.net/dwahlin/archive/2007/07/31/freeze-asp-net-gridview-headers-by-creating-client-side-extenders.aspx using extenders.

or check this,

http://www.codeproject.com/Articles/30592/Freezing-ASP-NET-GridView-Header-With-JavaScript-a

dipa ahuja replied to msakt on 24-May-12 10:50 AM

<style type="text/css">
  .WrapperDiv
  {
    width800px;
    height400px;
    border1px solid black;
  }
  
  .WrapperDiv TH
  {
    positionrelative;
  }
  
  .WrapperDiv TR
  {
    /* Needed for IE */
    height0px;
  }
</style>
<script>
  function onLoad() {
 
    FreezeGridViewHeader('GridView1''WrapperDiv');
  }
</script>

http://weblogs.asp.net/dwahlin/archive/2007/07/31/freeze-asp-net-gridview-headers-by-creating-client-side-extenders.aspx