RadRadGrid custom paging(用户自定义分页)

感觉 RadGrid 用户自定义分页和asp.net pager很相似

需要注意的是1.启用AllowCustomPaging=true;

                 2.设置VirtualItemCount=表的总记录数

详细代码如下;

==============================================

aspx

----------------------------------------------------------------------

 

ExpandedBlockStart.gif 代码
< div  class ="div1" >
< telerik:RadGrid  ID ="RadGrid1"  runat ="server"  AllowPaging ="True"  AllowSorting ="True"  GridLines ="None"  AllowMultiRowSelection ="True"  OnNeedDataSource ="RadGrid1_NeedDataSource"  AllowCustomPaging ="True" >
            
< HeaderContextMenu  EnableTheming ="True" >
                
< CollapseAnimation  Duration ="200"  Type ="OutQuint"   />
            
</ HeaderContextMenu >
            
< MasterTableView  AutoGenerateColumns ="False"  ClientDataKeyNames ="ZJID"  CommandItemDisplay ="Top"  NoMasterRecordsText ="没有记录显示" >
                                 
< Columns >
                    
< telerik:GridClientSelectColumn  Reorderable ="False"  UniqueName ="ClientSelectColumn"   >
                    
< ItemStyle  HorizontalAlign ="Center"   />
                        
< HeaderStyle  HorizontalAlign ="Center"  Width ="40px"   />
</ telerik:GridClientSelectColumn >
                    
< telerik:GridBoundColumn  DataField ="ID"  DataType ="System.Int32"  HeaderText ="序号"
                        ReadOnly
="True"  SortExpression ="ID"  UniqueName ="ID" >
                    
</ telerik:GridBoundColumn >
                    
< telerik:GridBoundColumn  DataField ="XM"  HeaderText ="姓名"  SortExpression ="XM"
                        UniqueName
="XM" >
                    
</ telerik:GridBoundColumn >
                                   
</ Columns >
                         
</ MasterTableView >
             
< SortingSettings  SortedAscToolTip ="正序"  SortedDescToolTip ="倒序"  SortToolTip ="单击排序"   />
           
< ClientSettings  EnableRowHoverStyle =True >
                
< Selecting  AllowRowSelect ="True"   />
                
< ClientEvents  OnRowDeselected ="rowdeSelected"  OnRowSelected ="rowSelected"   ></ ClientEvents >
            
</ ClientSettings >             

< ExportSettings  ExportOnlyData ="True"  IgnorePaging ="True"  OpenInNewWindow ="True" ></ ExportSettings >
            
< FilterMenu  EnableTheming ="True" >
                
< CollapseAnimation  Duration ="200"  Type ="OutQuint"   />
            
</ FilterMenu >
    
< PagerStyle  Mode ="Slider"   />
        
</ telerik:RadGrid >
    
</ div >

 

------------------------------

cs代码

 

ExpandedBlockStart.gif 代码
protected   void  Page_Load( object  sender, EventArgs e)
    {
        SqlHelper helper 
=   new  SqlHelper();

        
string  str  =   " select count(*) from Table1 " ;
        RadGrid1.VirtualItemCount 
=  ( int )helper.ExecuteScalar(str);

    }
 
protected   void  RadGrid1_NeedDataSource( object  source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        
int  startRowIndex  =  RadGrid1.CurrentPageIndex  *  RadGrid1.PageSize;
        SqlHelper helper 
=   new  SqlHelper();
        
// sql2005   
         string  str  =   " select * from (select * , row_number() over( order by ID) as n from Table1) as t where n between  "   +  startRowIndex  +   "  and   "   +  (startRowIndex  +  RadGrid1.PageSize)  +   "" ;
                DataSet dt 
=  helper.ExecuteDataSet(str);

        RadGrid1.DataSource 
=  dt;
    }

 

 

转载于:https://www.cnblogs.com/weiyuxinghuacun/archive/2009/12/29/1634735.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值