A simple way to fix a DataGrid table header

Source: Internet
Author: User
In the process of developing a ASP.net project, the customer asked us to make the header of all DataGrid tables look like an Excel form, and when the table has a lot of data, we can pull down the scroll bar and keep the header fixed. After the search on the internet found the following relatively simple method. The specific application is as follows:
1. Add a class to the CSS
. fixheaderstyle {
font-size:9pt;
Vertical-align:middle;
Text-transform:capitalize;
font-family: "Arial", "Helvetica", "Sans-serif";
height:25px;
Background-color: #ecf4fe;
Text-align:center;
Text-decoration:none;
position:relative; -The necessary
Top:expression (THIS.OFFSETPARENT.SCROLLTOP)--Necessary
}
On the page, similar code such as:
<div style= "Overflow:auto; width:100%; height:300px "align=" Center ">
<asp:datagrid Id=grdcurratevoy runat= "Server" width= "100%" visible= "True" >
<itemstyle cssclass= "ItemStyle" ></ItemStyle>
<pagerstyle cssclass= "PagerStyle" ></PagerStyle>
</asp:DataGrid>
</DIV>
It's done.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.