冻结DataGrid的Header的方法

费话少说先贴源码

<style type="text/css">
        .fixTitle 
{ POSITION: relative;  TOP: expression(this.offsetParent.scrollTop) }
        .fixCol 
{ POSITION: relative;  Left: expression(this.offsetParent.scrollLeft) }
        </style>


     < DIV  style ="Z-INDEX: 102; LEFT: 264px; OVERFLOW: auto; WIDTH: 184px; POSITION: relative; TOP: 128px; HEIGHT: 216px"
                ms_positioning
="GridLayout" >
                
< asp:DataGrid  id ="DataGrid1"  style ="Z-INDEX: 103"  runat ="server"  BorderColor ="#DEBA84"  BorderStyle ="None"
                    BorderWidth
="1px"  BackColor ="#DEBA84"  CellPadding ="0"  AutoGenerateColumns ="False" >
                    
< SelectedItemStyle  Font-Bold ="True"  ForeColor ="White"  BackColor ="#738A9C" ></ SelectedItemStyle >
                    
< ItemStyle  ForeColor ="#8C4510"  BackColor ="#FFF7E7" ></ ItemStyle >
                    
< HeaderStyle  Font-Bold ="True"  ForeColor ="White"   BackColor ="#A55129" ></ HeaderStyle >
                    
< FooterStyle  ForeColor ="#8C4510"  BackColor ="#F7DFB5" ></ FooterStyle >
                    
< Columns >
                        
< asp:BoundColumn  DataField ="IntegerValue"  HeaderText ="IntegerValue"   HeaderStyle-CssClass  ="fixCol"  ItemStyle-CssClass ="fixCol" ></ asp:BoundColumn >
                        
< asp:BoundColumn  DataField ="StringValue"  HeaderText ="StringValue" ></ asp:BoundColumn >
                        
< asp:BoundColumn  DataField ="CurrencyValue"  HeaderText ="CurrencyValue" ></ asp:BoundColumn >
                    
</ Columns >
                    
< PagerStyle  HorizontalAlign ="Center"  ForeColor ="#8C4510"  Mode ="NumericPages" ></ PagerStyle >
                
</ asp:DataGrid ></ DIV >

以前不知道从哪位高手那里看到的fixTitle的Css,在这里谢过了!

如果你想冻结那列就把 fixCol这个Css加到 那列的 HeaderStyle-CssClass 和  ItemStyle-CssClass 中去

这里我是冻结的第一列。



 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值