惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
IT之家
IT之家
S
SegmentFault 最新的问题
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
J
Java Code Geeks
博客园 - 聂微东
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
The Cloudflare Blog
博客园_首页
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
宝玉的分享
宝玉的分享
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
月光博客
月光博客
NISL@THU
NISL@THU
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
aimingoo的专栏
aimingoo的专栏
L
LINUX DO - 热门话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Fortinet All Blogs
博客园 - Franky
L
Lohrmann on Cybersecurity
S
Secure Thoughts
量子位
V
Vulnerabilities – Threatpost
Last Week in AI
Last Week in AI
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LINUX DO - 最新话题
I
InfoQ
C
CERT Recently Published Vulnerability Notes
Security Archives - TechRepublic
Security Archives - TechRepublic
P
Proofpoint News Feed
G
GRAHAM CLULEY
Cisco Talos Blog
Cisco Talos Blog

博客园 - 阿福

TypeScript forms authentication failed the ticket supplied was invalid错误 (Windows Server 2008 + IIS 7.5) jQuery Mobile 1.1.1 RC1发布 HashSet<T> vs List<T> 不要用把无序GUID既作为主键又作为聚集索引 WCF Data Services 5.0 RTM发布 EF Power Tools Beta 2发布 Entity Framework 5性能方面的注意事项 jQuery Mobile 1.1.0 RC2发布 源码+幻灯片:学习HTML5/jQuery/ASP.NET MVC/EF Code First的绝佳资源Account at a Glance项目 使用Autofac在ASP.NET Web API上实现依赖注入 在Windows Azure上开发ASP.NET程序与在Windows Sever上有何不同 充分利用缓存来提高网站性能 ASP.NET MVC 4, ASP.NET Web API, ASP.NET Web Pages v2 (Razor)全部开源,并接受来自社区的贡献(contributions) EF5 beta2通过NuGet发布 Getting Started with HTML5 开发HTML5应用你需要了解的 WCF入门资源 jquery history plugin, url hash Run Tasks in an ASP.NET Application Domain ASP.NET 2.0: 生成Excel报表 VS 2008 hot-fix终于出来了 Images; How to create an HTTP handler to dynamically resize images and change quality. ASP.NET 2.0: Add build-in paging feature to repeater/为repeater添加内置分页功能 Tip/Trick ASP.NET 2.0: DropDownList DataBind ASP.NET 2.0: Forms Authentication Across domains Ajax类库、框架、工具包完全列表 怀旧啊 Search Box ASP.NET 2.0: Site Maps Checking All CheckBoxes in a GridView Efficient Data Paging and Sorting with ASP.NET 2.0 and SQL 2005 JavaScript Calendar Cool MSDN ASP.NET 2.0 GridView Control Article Do I have to cry for you Google无法访问 扯淡 狗*! Atlas Control Toolkit and Source Code for the Build-in Asp.Net 2.0 Providers Great New Advanced Article on ASP.NET 2.0 Master Pages ASP.NET 2.0:通过SqlDataSource绑定数据到普通控件 不使用ISAPI或IIS wildcard实现不带扩展名URL的转向 VS 2005 Web Application Project & Atlas Control Toolkit & CSS Control Adapter ASP.NET 2.0 Language Swithcer and Theme Swicher 多语言转换和多样式主题转换 How to use virtual path providers to dynamically load and compile content from virtual paths in 
通过客户端扩展实现固定GridView表头功能
阿福 · 2010-01-01 · via 博客园 - 阿福

当GridView单页数据较多,需要纵向滚动数据时,我们通常将gridview包裹在一个div里面,然后设置div的样式。这种方式的缺点就是滚动时GridView的表头不能固定,会被滚动出视野。网上关于固定GridView表头的实现方式有很多,但大多比较繁琐,往往需要客户端或服务器端的很多附加代码。本例的作者只通过一段客户端脚本即实现了该功能。

<style type="text/css">
    .__GridViewClass th {
        position:relative;
    }
    .__GridViewClass tr 
    {
        
        height:0px;
    }  

</style>
<script>
    function onLoad()
    {
        //Called when page first loads
        FreezeGridViewHeader("GridView1",'400px','800px',"1px solid black",null);
    }    
    
    
    function FreezeGridViewHeader(gridID,h,w,wrapperDivBorderStyle,
      wrapperDivCssClass) 
    {
        /// <summary>Used to create a fixed GridView header and allow 
        /// scrolling</summary>
        /// <param name="gridID" type="String">Client-side ID of the 
        ///  GridView control</param>
        /// <param name="h" type="Number">Height of the scrollable grid</param>
        /// <param name="w" type="Number">Width of the scrollable grid</param>
        /// <param name="wrapperDivBorderStyle" type="String">CSS style to be 
        ///  applied to the GridView's wrapper div element</param>
        /// <param name="wrapperDivCssClass" type="String">CSS class to be 
        /// applied to the GridView's wrapper div element</param>
        var grid = document.getElementById(gridID);
        if (grid != 'undefined')
        {
            grid.style.visibility = 'hidden';
            grid.className = (grid.className == null || 
              grid.className == 'undefined' ||
              grid.className == '')?'__GridViewClass':grid.className + 
              ' __GridViewClass';
            if (grid.parentNode != 'undefined') 
            {
                //Find wrapper div output by GridView
                var div = grid.parentNode;
                if (div.tagName == "DIV")
                {
                    if (this._WrapperDivCssClass != null) 
                      div.className = wrapperDivCssClass;
                    div.style.height = ((h==null)?'400px':h);
                    div.style.width = ((w==null)?'800px':w);
                    if (wrapperDivBorderStyle != null) 
                      div.style.border = wrapperDivBorderStyle; 
                    div.style.overflow = "auto";
                }
            }                
            //Find DOM TBODY element and remove first TR tag from 
            //it and add to a THEAD element instead so CSS styles
            //can be applied properly in both IE and FireFox
            var tags = grid.getElementsByTagName_r('TBODY');
            if (tags != 'undefined')
            {
                var tbody = tags[0];
                var trs = tbody.getElementsByTagName_r('TR');
                if (trs != 'undefined') 
                {
                    var headTR = tbody.removeChild(trs[0]);
                    var head = document.createElement('THEAD');
                    head.appendChild(headTR);
                    grid.insertBefore(head, grid.firstChild);
                }
                tbody.style.height = (parseInt(h) * .92) + 'px';
                tbody.style.overflowX = "hidden";
            }
            grid.style.visibility = 'visible';
        }
    }
</script>   

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

补记:作者将该功能包装为一个 ajax tookit extender,可以更加方便的使用,下载。作者也介绍了该extender的具体实现步骤,可以读读,作为学习asp.net ajax toolkit extender实现的好资料,原文地址 http://weblogs.asp.net/dwahlin/archive/2007/08/08/creating-an-asp-net-ajax-toolkit-extender-control.aspx

ajax toolkit extender for freezing gridview headers