gridview分页中的问题 [英] problem in gridview paging

查看:75
本文介绍了gridview分页中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我想将Gridview与分页和排序一起使用.当我单击下一页时,它不会显示任何内容,而在单击搜索"按钮后,它将显示数据.我没有使用sqldatasource.我将其用作3tier架构.如何在下一页按钮上单击显示.如何进行页面排序?
我添加了这样的代码

Dear All,

I want to use Gridview with paging and sorting. When I click on the next page it will not show anything and after clicking on the "search" button, it will display the data. I am not using the sqldatasource. I am using it as a 3tier architecture. How to display in single click on the next page button. How to do the page sorting?
I added the code like this

protected void grdViewSearchResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdViewSearchResult.PageIndex = e.NewPageIndex;
        grdViewSearchResult.DataBind();
    }


请为此提供解决方案...


Please give me solution for this...

推荐答案

protected void grdViewSearchResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
            grdViewSearchResult.PageIndex = e.NewPageIndex;
            DataSet ds = new DataSet();
            ds = doctorSearch.getSearchResult();
            grdViewSearchResult.DataSource = ds.Tables[0];
            grdViewSearchResult.DataBind();
      }



如果这对您有帮助,那么请投票并接受答案:rose:



If this helped you then please Vote and accept the Answer :rose:


protected void grdViewSearchResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
            grdViewSearchResult.PageIndex = e.NewPageIndex;
            grdViewSearchResult.DataSource=//datasource; //BindGrid();
            grdViewSearchResult.DataBind();
      }


Madhukk,这是我的代码,
请检查一下,

< asp:GridView ID ="grdViewSearchResult" runat ="server"
Horizo​​ntalAlign ="Center" AllowPaging ="True" AllowSorting ="True"
onpageindexchanging ="grdViewSearchResult_PageIndexChanging"
onsorting ="grdViewSearchResult_Sorting" PageSize ="5"
EnableSortingAndPagingCallbacks ="True">

受保护的无效btnSearch_Click(对象发送者,EventArgs e)
{
DataSet ds = new DataSet();
ds = doctorSearch.getSearchResult();
grdViewSearchResult.DataSource = ds.Tables [0];
grdViewSearchResult.DataBind();
}

受保护的void grdViewSearchResult_PageIndexChanging(对象发送者,GridViewPageEventArgs e)
{
grdViewSearchResult.PageIndex = e.NewPageIndex;
grdViewSearchResult.DataSource = ds.Tables [0];
grdViewSearchResult.DataBind();
}
Madhukk, this is my code,
please check this,

<asp:GridView ID="grdViewSearchResult" runat="server"
HorizontalAlign="Center" AllowPaging="True" AllowSorting="True"
onpageindexchanging="grdViewSearchResult_PageIndexChanging"
onsorting="grdViewSearchResult_Sorting" PageSize="5"
EnableSortingAndPagingCallbacks="True">

protected void btnSearch_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds = doctorSearch.getSearchResult();
grdViewSearchResult.DataSource = ds.Tables[0];
grdViewSearchResult.DataBind();
}

protected void grdViewSearchResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdViewSearchResult.PageIndex = e.NewPageIndex;
grdViewSearchResult.DataSource = ds.Tables[0];
grdViewSearchResult.DataBind();
}


这篇关于gridview分页中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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