【问题标题】:GridView Button Not Setting When Reloading GridView重新加载 GridView 时未设置 GridView 按钮
【发布时间】:2013-07-19 20:39:02
【问题描述】:

我正在以编程方式填充 GridView,并且启用了分页。我的 GridView 填充在 DropDown_SelectedIndexChanged 处理程序上,它成功加载了新选择的第一页。我通过将 PageIndex 重置为 0 来做到这一点。但是,当我在下拉列表中选择一个新值时,页面按钮(使用数字页面按钮)不会重置。所以我们显示了第 1 页,但选择了第 5 页按钮(或我最后单击的任何一个)。这可能会让用户感到困惑。如何重置选中的按钮?有没有设置选中按钮进行分页的属性?

编辑:下面的代码真的是我所拥有的。 populatePanelGridView() 函数没有做任何与页面相关的事情,它只是添加项目。

    protected void DropDown_SelectedIndexChanged(object sender, EventArgs e) //changing the dropdown selection (aka when the page should revert to 1)
{
    populatePanelGridView();
    PanelGridView.PageIndex = 0;

}

    protected void PanelGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) //changing the page
{
    PanelGridView.PageIndex = e.NewPageIndex;
    populatePanelGridView();

}

【问题讨论】:

  • 添加了一些代码,我对页面的帮助并不多......
  • 添加了更多代码,抱歉。

标签: c# asp.net gridview


【解决方案1】:

你必须反过来做,先把PageIndex改成DataBindGridView

PanelGridView.PageIndex = 0;
populatePanelGridView();

【讨论】:

  • 我还有一些问题。我会进一步调查并回到这里。
  • 我在错误的代码部分进行了此更改。这行得通。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-11
相关资源
最近更新 更多