留言簿

我要留言
留言搜索

2006-11-12 22:25  蛐蛐

请问能在三层结构下使用该控件吗?

具件要如何使用,可否提供一个示例?

谢谢!
回复:当然可以的,不过现在没有这样的示例,三层结构的话获取分页的数据一般用存储过程实现,不用存储过程的话也可以在数据访问层或业务逻辑层来筛选当前页的数据然后做为业务对象的集合返回表现层。谢谢!

2006-11-09 15:02  zacard

请问一下,我想奖以下代码写在类别调用应该怎样写啊??感觉每个分页都要这样写觉得怪怪的!!
    protected Class Class = new Class();
    protected void Page_Load(object sender, EventArgs e)
    {
            string sort = DropDownList1.Text;
            SqlCommand cmd = new SqlCommand("newpro", Class.sqlconnection1);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@pageindex", SqlDbType.Int).Value = 1;
            cmd.Parameters.Add("@pagesize", SqlDbType.Int).Value = 1;
            cmd.Parameters.Add("@docount", SqlDbType.Bit).Value = true;
            cmd.Parameters.Add("@sort", SqlDbType.VarChar, 20).Value = sort;
            Class.sqlconnection1.Open();
            AspNetPager1.RecordCount = (int)cmd.ExecuteScalar();
            Class.sqlconnection1.Close();
            BindData();
    }

    void BindData()
    {
        string sort = DropDownList1.Text;
        SqlCommand cmd = new SqlCommand("newpro", Class.sqlconnection1);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@pageindex", SqlDbType.Int).Value = AspNetPager1.CurrentPageIndex;
        cmd.Parameters.Add("@pagesize", SqlDbType.Int).Value = AspNetPager1.PageSize;
        cmd.Parameters.Add("@docount", SqlDbType.Bit).Value = false;
        cmd.Parameters.Add("@sort", SqlDbType.VarChar, 20).Value = sort;
        Class.sqlconnection1.Open();
        DataList1.DataSource = cmd.ExecuteReader();
        DataList1.DataBind();
        Class.sqlconnection1.Close();
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        Literal1.Text = sb.Append("搜索到:<font color=\"blue\"><b>" + AspNetPager1.RecordCount.ToString() + "</b></font>款新品").ToString();
    }
回复:对不起,不太懂您的意思,您要实现类似搜索的功能吗?每个分页是什么意思呢?搜索的话您可以参考4.3.4版控件中带的查询的例子,谢谢!

2006-11-08 21:12  baal

您好,我上次问过一个问题,我是baal,关于changePage 函数,我现在做页面的方法是 不使用 事件,回归到asp的方式,每次都用链接都用url方式,所以每个页面都page_load 都执行,那个changePage是个事件,有方法避免吗?
回复:您好,看来您对asp.net的运行机制不是很熟悉,您既然用asp.net开发,为什么又使用asp的方式?AspNetPager是asp.net控件,如果不写PageChanged事件处理程序就无法实现分页,如果您要象asp那样自己处理分页,那就不需要用这个控件,自己写代码来显示分页按钮及页面链接。谢谢!

2006-11-07 14:11  一一

aspnetpager2005绑定到GridView,存储过程里用了视图,也出现了记录叠加,不知道什么原因?
回复:您取出来的记录就有重复的,出现这种问题,一般是由于用于标识记录唯一性的字段的值不是唯一的,有重复的值,请检查您的数据。谢谢!

2006-11-06 11:13  baal

urlpaging方式下,那个
ChangePage这个函数是不是还是需要的?否则e.NewPageIndex 这个参数就得不到值?那么分页控件的页码总是指向第一页?我这里的使用方法是这样的:protected void Page_Load(object sender, EventArgs e)
    {

       
        try
        {
            
            PagerId = Request.QueryString["page"] == null ? 1 : Convert.ToInt32(Request.QueryString["page"]);
        }
        catch (Exception err)
        {
            
        }

        
        BindData(PagerId);

    }

    public void ChangePage(object src, PageChangedEventArgs e)
    {
        BindData(e.NewPageIndex - 1);
    }

    private int BindData(decimal PageIndex)
    {
        Pager1.CurrentPageIndex = (int)PageIndex+1;
.......查询数据,这里只是得到一个datatable,在前台for 输出,没有使用asp。net控件

urlpaing方式下,page_load 和ChangePage 每次都会 调用,这样就binddata两次了,多查询了数据库,但我在page_load 里去掉binddata 或把 ChangePage去掉,分页控件的页面就始终停留在第一页!不知道斑竹明白我的意思么?
回复:您好,不管用什么方式分页,您都必须为PageChanged这个事件编写事件处理程序,否则无法实现分页。您上面的代码是错误的,没必要自己从url获取当前页索引,url分页情况下只需要在PageChanged事件处理程序中绑定数据就行了,不需要再在Page_Load中绑定,否则就象您说的会绑定两次数据。有关url分页的示例,请参考控件的示例代码。谢谢!

2006-11-06 10:06  阮新军

接口如下,但是还是希望老大提供一个通用的接口
using System;
using System.Collections;

using Model;

namespace IDAL
{
	/// <summary>
	/// Search Record by param 
	/// </summary>
	public interface IPaging
	{

		IList UltraNewsSort(int iSortID,int iCatalogID,int iCurrentPageIndex,int iPageSize,bool bDoCount);

		//Recommend news
		IList UltraNewsSort(int iCatalogID,int iCurrentPageIndex,int iPageSize,bool bDoCount);

		IList UltraNewsAuthor(int iCatalogID,string strAuthor,int iCurrentPageIndex,int iPageSize,bool bDoCount);

		IList UltraNewsNewest(int iCatalogID,int iCurrentPageIndex,int iPageSize,bool bDoCount);

		IList UltraNewsHot(int iCatalogID,int iCurrentPageIndex,int iPageSize,bool bDoCount);

		IList MovieCategory(string strCategoryName,int iCurrentPageIndex,int iPageSize,bool bDoCount);

		IList MovieSort(int iSortID,int iCurrentPageIndex,int iPageSize,bool bDoCount);

		IList NewsAuthor(string strAuthor,int iCurrentPageIndex,int iPageSize,bool bDoCount);

		string testFunc();

	}
}
回复:很好的主意,不过我还有点不太理解,能否把您的代码发过来一份让我参考一下?也可以有空多交流,我的MSN就是首页显示为图片的hotmail电子邮件地址。谢谢!

2006-11-06 09:57  阮新军

看来,我只有用接口实现变通了,麻烦啊

2006-11-06 09:43  阮新军

感谢吴旗的的控件,我有一个小问题,如果我有N个页面,每个页面都要分页,用分页控件当然可以实现,但是每个页面的参数都不一样,就是说有N个存储过程,存储过程里面的变量总数都不一致,您能否提供一个通用的模型,我不喜欢JIT编译,用的三层架构,整个项目运行在dll里面,您的分页示例很好,但是不够灵活,可否写一个通用的.cs文件,在程序里面我自己控制存储过程的参数,您看一下代码!!
		#region 分页模块

		//绑定数据
		public  void BindData()
		{

			this.CommonBind(); //启动数据模块

			//...在此处加入业务逻辑
			//...该业务逻辑在外部进行存储过程参数渗透
			//cmd.Parameters.Add("@proname","浙江省");
			
			rad = cmd.ExecuteReader(); //执行数据

			this.JoinGrid();//合并数

		}

		//显示翻页数据
		public void ShowPager()
		{
			  
			this.CommonFen();//页面第一次开启,默认绑定数据

			//...在此处加入业务逻辑
			//...该业务逻辑在外部进行存储过程参数渗透
			//cmd.Parameters.Add("@proname","浙江省");
			  
			this.GetAndClose();
			   
			BindData();	//绑定数据

		 }

		//绑定翻页事件
		public void BindChange(object source,pager.PageChangedEventArgs c)
		{
			mypager.CurrentPageIndex = c.NewPageIndex;
			this.BindData();
		 }

		#endregion

我每次都要重复调用,还要重写,多麻烦啊

2006-11-04 20:58  cheap viagra

Good site, men. Thank you!
See U. Elena.
回复:I'm soryy but you're wrong to post ads here repeatedly! We're all very young programmers and don't need viagra:) thanks!

2006-11-04 13:55  阮新军

aspnetpager绑定到sql server视图的时候,记录会叠加??怎么办
回复:您好,这和控件没有关系,记录重复是因为您的视图中用于标识记录唯一性的字段的值不是唯一的,请检查您的视图及分页存储过程或SQL语句。谢谢!
;