Click here to Skip to main content
15,921,382 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi member I have a grid view inside a div which is the div that enable the scrolling as of now. However I would like to know how do I freeze the header while scrolling? I would like the header to still stay within the div thus there is a need to enable x & y scrolling as I do have many columns. I do not mind if its the div that scrolls or the grid view that scrolls.

ASP.NET
<div style="width: 100%; height: 400px; overflow: auto" >
     
        <asp:GridView ID="Gridview1" runat="server" AllowSorting="True" AutoGenerateColumns="False" Width="100%" GridLines="Horizontal"  BorderStyle="Solid"  OnRowDataBound ="Gridview1_OnRowDataBound">
            <AlternatingRowStyle BackColor="White" />
            <columns>
                <asp:boundfield DataField="Columm1" HeaderText="Columm1"></asp:boundfield>
                <asp:boundfield DataField="Columm2" HeaderText="Columm2"></asp:boundfield>
                <asp:boundfield DataField="Columm3" HeaderText="Columm3"></asp:boundfield>
                <asp:boundfield DataField="Columm4" HeaderText="Columm4"></asp:boundfield>
                <asp:boundfield DataField="Columm5" HeaderText="Columm5"></asp:boundfield>
                <asp:boundfield DataField="Columm6" HeaderText="Columm6"></asp:boundfield>
                <asp:boundfield DataField="Columm7" HeaderText="Columm7"></asp:boundfield>
                <asp:boundfield DataField="Columm8" HeaderText="Columm8"></asp:boundfield>
                <asp:boundfield DataField="Columm9" HeaderText="Columm9"></asp:boundfield>           
            </columns>
            <EditRowStyle BackColor="#2461BF" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="False" ForeColor="Black" BorderStyle="Solid" BorderWidth="2px" />
                    </asp:GridView>

    </div><br />
Posted
Updated 26-Sep-15 20:48pm
v3
Comments
Sinisa Hajnal 28-Sep-15 2:38am    
Next time search around before posting a question. It is easily found and you wouldn't have to wait a day for an answer. Thank you.

1 solution

you can find example here
GridView with Fixed Header and Scroll Bar[^]

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900