【问题标题】:DataPager not working on first clickDataPager 在第一次点击时不起作用
【发布时间】:2014-04-05 08:29:43
【问题描述】:

我有一个用户控件,我将它放在 Default.aspx 上。在 Default.aspx 我有这个代码:

   ds = FillFromDatabase();
        Session["note"] = ds.Tables[0];

usercontorl 我有这个代码:

 if (Session["note"] != null)
        {
            ListView1.DataSource = Session["note"] as DataTable;
            ListView1.DataBind();

        }

listview 有一个datapager,有 5 页。当我点击下一页时它没有工作当我再次点击下一页时它工作正常。有什么想法吗?

【问题讨论】:

  • 你在哪里填充会话[note];也许在点击事件上?
  • @Pleun 是的,我在按钮单击中填写会话 [“note”] 但这一行 * ds = FillFromDatabase();会话["note"] = ds.Tables[0]; * 正在页面加载中

标签: c# asp.net datapager


【解决方案1】:

我找到了解决方案:

protected void ListView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
    {
        DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
        DbAccessor db1 = new DbAccessor();
       ListView1.DataSource = fillFromDb();

        ListView1.DataBind();
    }

【讨论】:

    猜你喜欢
    • 2013-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多