更改页面时,不在datagrid视图中显示最近选择的页面的内容 [英] not display the content of recently selected page in datagrid view when page is changed

查看:70
本文介绍了更改页面时,不在datagrid视图中显示最近选择的页面的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生.

我在asp.net中有一个gridview控件.它有一个编辑链接按钮.当我单击另一页时打开.我在网格视图中使用内置分页.假设我有5页.我的问题是当我从2,3,4页返回,然后从另一页返回到默认具有网格视图的页面,该页面显示第一页的内容而不显示最近选择的页面的内容.

谢谢长官..

Randeep Chauhan

Hi Sir..

I have a gridview control in asp.net .It have a edit link button.when i click on this other page is open.I am using inbuilt paging in grid view .Suppose i have 5 page in it.My problem is that when i go from 2,3,4 page and go back from other page to page in which page have grid view by default it display th content of first page not display the content of recently selected page.

Thanks sir..

Randeep Chauhan

推荐答案

执行以下操作.

1.在Page_Load事件中绑定GridView.
2.实现GridView的PageIndexChanging事件.

Do the following.

1. Bind the GridView in Page_Load event.
2. Implement PageIndexChanging event of the GridView.

protected void Page_Load(object sender, System.EventArgs e)
{
    if (!IsPostBack) {
        bindControls();
    }
}

protected void GridView1_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
    bindControls();
}

private void bindControls()
{
    BusinessLogicFacade businessLogic = new BusinessLogicFacade();// Change to your data source class and bind the GridView.
    GridView1.DataSource = businessLogic.GetData();
    GridView1.DataBind();
}


Protected Sub grdGoods_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdGoods.PageIndexChanging
    grdGoods.PageIndex = e.NewPageIndex
    grdGoods.DataSource =  DataTable 'that is populated by a query
    grdGoods.DataBind()
End Sub


这篇关于更改页面时,不在datagrid视图中显示最近选择的页面的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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