IBatisNet如何不使用ADO.NET中的DataSet、DataTable、DataRow等对象实现分页(也就是用其自带对象、属性或方法实现分页)?可以结合AspNetPagger分页控件实现吗?谢谢!

解决方案 »

  1.   

    IBatisNet如何不使用ADO.NET中的DataSet、DataTable、DataRow等对象实现分页(也就是用其自带对象、属性或方法实现分页)?
    应该是如何使用吧....可以参考
    http://www.cnblogs.com/mail-ricklee/archive/2008/07/29/1255873.html
    中的IBatisNet里面修改了QueryFor(Oracle)DataTable等等方式...
      

  2.   

    IBatisNet和AspNetPagger 没有什么直接联系.
    你从IbatisNet获得的数据赋给AspNetPagger 控件就可以.
    AspNetPagger 是支持IList对象的.Ibatis里一般查询返回的数据集都是IList对象的.
      

  3.   


    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Collections;
    using System.Collections.Generic;using DYJ.CMS.DAO;
    using DYJ.CMS.DAO.Implement;
    using DYJ.CMS.DAO.Interface;
    using DYJ.CMS.Model;
    using DYJ.CMS.Template.project;
    using DYJ.CMS.Service.Enum;public partial class projects_project_manage : BasePage
    {
        private int pageSize = 20;
        IProjectInfoDao dao = CastleContext.Instance.GetService<IProjectInfoDao>();    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                #region 下面的代码用于为 自动分页组件对象 初始化            //定义分页数量
                myPager.PageSize = pageSize;            #endregion            BoundProjectList(1);
            }
        }    // 删除操作
        protected void repProjectList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName.ToLower() == "delete")
            {
                ProjectInfo curProject = new ProjectInfo();            curProject.ProjectID = Convert.ToInt64(e.CommandArgument);
                dao.Delete(curProject);            RecordUserOperLog(LogTypes.DeleteProject, string.Format(LogMessage.DeleteProjectMsg, "项目ID:" + curProject.ProjectID.ToString() +
                    "项目名称:" + curProject.ProjectName, "成功"));            BoundProjectList(myPager.CurrentPageIndex);
            }
        }    /// <summary>
        /// 项目列表绑定
        /// </summary>
        private void BoundProjectList(int pageIndex)
        {
            IList<ProjectInfo> list = ProjectProc.ProjectPaging(pageSize, pageIndex, "ProjectID", true);        FormatPagingComonent(dao.GetCount());        repProjectList.DataSource = list;
            repProjectList.DataBind();
        }    # region mypager    /// <summary>
        /// 本方法用于动态的为 自动分页组件 实现页数的功能
        /// </summary>
        /// <param name="rowCount"></param>
        private void FormatPagingComonent(int rowCount)
        {
            //求取记录总数
            myPager.RecordCount = rowCount;        //若当前总记录总数不大于 一页 的记录数目,则不显示自动分页控件
            if (rowCount <= pageSize)
            {
                if (this.myPager.Visible)
                {
                    this.myPager.Visible = false;
                }
            }
            //若当前总记录总数大于 一页 的记录数目,则显示自动分页控件
            else
            {
                if (!this.myPager.Visible)
                {
                    this.myPager.Visible = true;
                }
            }       // ShowPagingContext();
        }    protected void myPager_PageChanged(object sender, EventArgs e)
        {
            //重新绑定
            this.BoundProjectList(this.myPager.CurrentPageIndex);
        }    # endregion
    }