首页 新闻 搜索 专区 学院

AspNetPager 分页

0
悬赏园豆:5 [已关闭问题]

第一次加载时显示正确的数据

可是当变换数据源的时候,数据库空间能显示正常的数据,而分页空间仍然是第一次加载时的情形(没有变化)代码如下:

    public string xe = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }
    protected void Bind()
    {
        Repeater1.DataSource = DAL.producttype.TypeoneList();
        Repeater1.DataBind();
        Repeater1.AutoUpdateAfterCallBack = true;
        if(xe=="yes")
        {
            int num = Convert.ToInt32(DBUtility.DbHelperOleDb.GetSingle("select count(uid) from Product where [Pistop]=1 and [Ptype]=" + Convert.ToInt32(ViewState["type"].ToString())).ToString());
            AspNetPager1.RecordCount = num;
            DataList1.DataSource = DAL.product.Product_istop_type(1, Convert.ToInt32(ViewState["type"].ToString()), this.AspNetPager1.PageSize * (this.AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize);
            DataList1.DataBind();
            DataList1.AutoUpdateAfterCallBack = true;
            return;
        }
        int count = Convert.ToInt32(DBUtility.DbHelperOleDb.GetSingle("select count(uid) from Product where [Pistop]=1").ToString());
        AspNetPager1.RecordCount = count;
        DataList1.DataSource = DAL.product.Product_istop(1, this.AspNetPager1.PageSize * (this.AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize);
        DataList1.DataBind();
        DataList1.AutoUpdateAfterCallBack = true;
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        Bind();
    }
    /// <summary>
    /// 搜索产品
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Txt_key.Text.Trim().ToString() == "")
        {
            Anthem.Manager.AddScriptForClientSideEval("alert('您输入的产品名为空!')");
            return;
        }
        int count = Convert.ToInt32(DBUtility.DbHelperOleDb.GetSingle("select count(uid) from [Product] where [Pistop]=1 and [Pname] like '%" + Txt_key.Text.Trim() + "%'"));
        if (count > 0)
        {
            Txt_key.Text = "";
            Txt_key.AutoUpdateAfterCallBack = true;
            DataList1.DataSource = DBUtility.DbHelperOleDb.Query("select * from [product] where [Pistop]=1 and [Pname] like '%" + Txt_key.Text.Trim() + "%' ORDER BY [UID] desc");
            DataList1.DataBind();
            DataList1.AutoUpdateAfterCallBack = true;
            return;
        }
        Anthem.Manager.AddScriptForClientSideEval("alert('不存在该产品,或者输入过于复杂!')");
        Txt_key.Text = "";
        Txt_key.AutoUpdateAfterCallBack = true;
        Bind();
    }
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "choose")
        {
            xe = "yes";
            ViewState["type"] = Convert.ToInt32(e.CommandArgument.ToString());
            Bind();
        }
    }

敬请赐教!!!

Tiger2009的主页 Tiger2009 | 初学一级 | 园豆:181
提问于:2009-07-20 12:42
< >
分享
其他回答(2)
0

我也遇到过  一般这个问题  都出现  要检查 (!IsPostBack)
不是多了就是少了,或者逻辑不对

牛牛博客 | 园豆:305 (菜鸟二级) | 2009-07-20 17:16
0
Insus.NET | 园豆:932 (小虾三级) | 2009-07-20 18:01
0

检查 (!IsPostBack)

弑爱 | 园豆:235 (菜鸟二级) | 2009-07-20 21:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册