Pageindex更改不起作用 [英] Pageindex changing not working

查看:106
本文介绍了Pageindex更改不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


PageIndexChanging的编码


Coding for PageIndexChanging

GridBank.PageIndex = e.NewPageIndex;
GridBank.DataSource = (DataTable)ViewState["Bank"];
GridBank.DataBind();



当我单击第二页或第三页时,它正在显示该页面,但是当我单击第二页或第三页的SelectIndex时,它正在选择索引的第一页,因此任何人对
因此,请为此提供一些解决方案.谢谢



when i click the second page or third page, it was showing the page, but when i click the SelectIndex of the second or third page, it is selecting the first page of the index, so anyone have any idea about the PageIndex
So please give some solution for this. thanks

推荐答案

这完全是猜测.

我想您也已经编写了用于在Page_Load上加载GridView的代码.如果是,请确保检查IsPostback属性并加载GridView.

喜欢,

This is completely a guess.

I guess you have written code for loading the GridView on the Page_Load too. If yes, make sure you check for IsPostback property and load the GridView.

Like,

private void Page_Load (object sender, EventArgs e)
{
    if (!IsPostback)
    {
        //load your GridView here
    }
}



将其标记为答案(如果有帮助的话).



Mark it as answer if it is helpful.


以下MSDN文章应为您提供有关datagrid分页工作原理和相关代码的完整概述:
MSDN DataGrid.PageIndexChanged事件 [ ^ ]
MSDN:创建可分页,可排序的数据网格 [
Following MSDN articles should give you complete overview of how datagrid''s pagination work and the related code:
MSDN DataGrid.PageIndexChanged Event[^]
MSDN: Creating a Pageable, Sortable DataGrid[^]


在网页上调用任何事件时PageLoad会在此之前获得调用.
您可能没有将IsPostBack放在PageLoad中
When any event called on web page the PageLoad get calls prior that.
It may happens that you have not put IsPostBack in your PageLoad


这篇关于Pageindex更改不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆