SqlPager控件使用心得[续]

应一些朋友的邀请,我在这里写我的一些使用和修改SqlPager的详细说明:
1.要使用SqlPager首先要导入您已经修改好的SqlPager.DLL
2.在页面的前台:
ExpandedBlockStart.gif ContractedBlock.gif <% dot.gif @ Register TagPrefix="cc1" Namespace="HLSqlPager" Assembly="sqlpager"  %>
None.gif < cc1:sqlpager  id ="SqlPager1"  runat ="server"  ConnectionString ="server=(local);database=test;uid=sa;pwd=123"
None.gif                                        ItemsPerPage
="12"  ControlToPaginate ="dg"  Width ="250px"  SortMode ="DESC" ></ cc1:sqlpager >
None.gif < asp:datagrid  id ="dg"  runat ="server"  Width ="100%"  BorderWidth ="0"  ShowHeader ="False"  AutoGenerateColumns ="False" >
None.gif                                        
< ItemStyle  BorderWidth ="0" ></ ItemStyle >
None.gif                                        
< Columns >
None.gif                                            dot.gifdot.gifdot.gifdot.gif                                        
</ Columns >
None.gif                                    
</ asp:datagrid >
None.gif < cc1:sqlpager  id ="SqlPager2"  runat ="server"  ConnectionString ="server=(local);database=test;uid=sa;pwd=123"
None.gif                                        ItemsPerPage
="12"  ControlToPaginate ="dg"  Width ="250px" ></ cc1:sqlpager >
注意: ControlToPaginate ="dg"   这里的dg是你要绑定数据的控件名(只能是DataGrid 或者DataList)

3.后台数据绑定函数
ExpandedBlockStart.gif ContractedBlock.gif /**/ /// <summary>
InBlock.gif        
/// SqlPager数据绑定到指定控件
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="SQL">指定查询SQL</param>
InBlock.gif        
/// <param name="sortfield">排序字段</param>
ExpandedBlockEnd.gif        
/// <param name="sortmode">排序方法</param>

None.gif          private   void  BindGrid( string  SQL, string  sortfield, string  sortmode)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {                    
InBlock.gif            SqlPager1.SelectCommand
=SQL;
InBlock.gif            SqlPager2.SelectCommand
=SQL;
InBlock.gif            SqlPager1.SortField
=sortfield;
InBlock.gif            SqlPager2.SortField
=sortfield;
InBlock.gif            
if(sortmode=="DESC")
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                SqlPager1.SortMode
=HLSqlPager.SortMode.DESC;
InBlock.gif                SqlPager2.SortMode
=HLSqlPager.SortMode.DESC;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                SqlPager1.SortMode
=HLSqlPager.SortMode.ASC;
InBlock.gif                SqlPager2.SortMode
=HLSqlPager.SortMode.ASC;
ExpandedSubBlockEnd.gif            }
            
InBlock.gif            HLSqlPager.SqlPager sqlp
=new HLSqlPager.SqlPager();
InBlock.gif            
InBlock.gif            
this.DataBind();
ExpandedBlockEnd.gif        }

4.两个SqlPager联动
None.gif private   void  sql1_pager( object  sender, HLSqlPager.PageChangedEventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            SqlPager2.CurrentPageIndex
=SqlPager1.CurrentPageIndex;
InBlock.gif            SqlPager2.DataBind();
ExpandedBlockEnd.gif        }

None.gif
None.gif        
private   void  sql2_pager( object  sender, HLSqlPager.PageChangedEventArgs e)
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif            SqlPager1.CurrentPageIndex
=SqlPager2.CurrentPageIndex;
InBlock.gif            SqlPager1.DataBind();
ExpandedBlockEnd.gif        }
None.gif private   void  InitializeComponent()
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {                         this.SqlPager1.PageIndexChanged += new HLSqlPager.SqlPager.PageChangedEventHandler(this.sql1_pager);
InBlock.gif            
this.SqlPager2.PageIndexChanged += new HLSqlPager.SqlPager.PageChangedEventHandler(this.sql2_pager);
InBlock.gif            
this.Load += new System.EventHandler(this.Page_Load);
InBlock.gif
ExpandedBlockEnd.gif        }

5.切图
{FEE9544D-30BD-4C28-9F1A-3018C7383775}.BMP
6.说明
您可以按照自己的需要对SqlPager进行修改
原版下载地址: 下载本文的源代码(英文)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值