Solved

ASP.Net Datagrid - Scrolls and Sorts on Headers - Can I fix the Header as Well?

Posted on 2009-07-08
2
214 Views
Last Modified: 2012-06-22
The title pretty much says it all. I just want the headers to stay put while I'm scrolling through the data. The existing code is below.

Thanks!!
<div style= "height:300px; overflow:auto;">           	     

	        <asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" runat="server" DataKeyNames="Sequence"

            ForeColor="Black" ShowFooter="True" CellPadding="5"                  

            BackColor="White" BorderWidth="1px" BorderStyle="None" BorderColor="#CCCCCC" 

                 Height="135px" AllowSorting="True" AutoGenerateColumns="False">

                <Columns>

                    <asp:BoundField DataField="Dept" HeaderText="Department" ReadOnly="True"

                        SortExpression="Dept" />

                    <asp:BoundField DataField="DeptNum" HeaderText="Dept #" SortExpression="DeptNum" />

                    <asp:BoundField DataField="ZoneMgr" HeaderText="Zone Mgr" ReadOnly="True"

                        SortExpression="ZoneMgr" />

                    <asp:BoundField DataField="Phone" HeaderText="Phone" ReadOnly="True" 

                        SortExpression="Phone" />

                    <asp:BoundField DataField="Email" HeaderText="Email" ReadOnly="True" 

                        SortExpression="Email" />

                    <asp:BoundField DataField="BackupZM" HeaderText="Backup Zone Mgr" ReadOnly="True" 

                        SortExpression="BackupZM" />

                    <asp:BoundField DataField="BackupPhone" HeaderText="Backup Phone" ReadOnly="True" 

                        SortExpression="Backup Phone" />

                    <asp:BoundField DataField="BackupEmail" HeaderText="Backup Email" ReadOnly="True" SortExpression="BackupEmail" />

                 </Columns>

            <HeaderStyle Font-Bold="true" Wrap="false" ForeColor="White" BackColor="#333333" /> 

            <FooterStyle Font-Bold="true" Wrap="false" ForeColor="White" BackColor="#333333" />                

            <AlternatingRowStyle Font-Bold="True" Wrap="False" ForeColor="black" BackColor="#CCCC99"></AlternatingRowStyle>

            </asp:GridView>

   </div> <!-- end gridview-container -->             

	        <asp:SqlDataSource ID="SqlDataSource1" runat="server"

	            SelectCommand="SELECT * FROM [ZMDeptsList]"

                ConnectionString="<%$ ConnectionStrings:MyConnection %>"                  

                DataSourceMode="DataSet">

             </asp:SqlDataSource>

Open in new window

0
Comment
Question by:JB4375
2 Comments
 
LVL 8

Accepted Solution

by:
MrAgile earned 500 total points
ID: 24809241
0
 
LVL 1

Author Closing Comment

by:JB4375
ID: 31601331
Thanks. I'd seen some of these but I think the code project article might do the trick.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why don't I see this table in EDMX file? 2 23
Asp.net mvc 5 5 43
SQL Login 17 40
ASP.net show message while code is running 3 8
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now