0

I need to freeze the grid view header on scrolling grid view. Assigned data's to data table and binding it to gridview called 'report'. I tried a lot, but it is not working.. Can any one help me?

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true">
    <ContentTemplate>
        <center>
           <asp:Label ID="mess" runat="server" Font-Bold="true" ForeColor="Red"></asp:Label>
        </center>                        
        <div class="table_outer_n">
           <asp:GridView ID="report" runat="server"  Width="100%" HeaderStyle-CssClass="Freezing"></asp:GridView>
           <asp:GridView ID="gvDetails" runat="server" Visible="true"></asp:GridView> 
        </div>
     </ContentTemplate>
     <Triggers>
        <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
        <asp:PostBackTrigger ControlID="report" />
        <asp:PostBackTrigger ControlID="gvDetails" />
        <asp:PostBackTrigger ControlID="btndwn" />
      </Triggers>
</asp:UpdatePanel> 

//Code behind
DataTable claims = new DataTable();   
//.....datatable codes goes here
dr["REMARKS"] = remarks;
dr["VALIDATION"] = validation;
DataRow dr = claims.NewRow();
claims.Rows.Add(dr);

report.DataSource = claims;
report.DataBind();

//css
.Freezing {
   position:relative ;
   top:expression(this.offsetParent.scrollTop);
   z-index: 10;
}
Uriil
  • 11,948
  • 11
  • 47
  • 68
Varghese
  • 121
  • 2
  • 5
  • 15
  • possible duplicate question http://stackoverflow.com/questions/9648727/freeze-the-header-scroll-the-gridview – pmtamal Jul 08 '14 at 05:44

2 Answers2

1

you can try like this:

 <div style ="height:200px; width:617px; overflow:auto;">
// Your Grid View

 <asp:GridView ID="report" runat="server"  Width="100%" >
</asp:GridView>
 </div>

Source: Source code with Live Demo

Dgan
  • 10,077
  • 1
  • 29
  • 51
0

Please follow this link On CodeProject

you need to set the header style as

<style type="text/css">
    .FixedHeader {
        position: absolute;
    }     
</style>   

HeaderStyle-CssClass="FixedHeader"

Or as comment suggested this answer on stackoverflow would help you too

Community
  • 1
  • 1
Ashish Rajput
  • 1,489
  • 1
  • 11
  • 20