页面索引更改中的问题. [英] problem in page index changing....

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

问题描述

我有20行数据,但在一页中仅显示11行,而其下一页没有移动...在plzzzzz下面给出的代码告诉我问题在代码下面或其他地方...

axpx页面:-

i am having 20 row data but showing 11 in one page only its not moving next page...code given below plzzzzz tell me that prblem is below code or some where else.....

The axpx page:-

<asp:gridview id="grdJobHistory" bordercolor="AliceBlue" runat="server" cellpadding="4" ¬
font-names="verdana" font-size="Small" forecolor="#333333" gridlines="Vertical" ¬
xmlns:asp="#unknown">
Width="100%" AutoGenerateColumns="False" AllowPaging="True" ¬
OnPageIndexChanging="grdJobHistory_PageIndexChanging">




后台代码:-




The code-behind page:-

protected void grdJobHistory_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        if (Convert.ToString(Request.QueryString["empcode"].ToString()) != "")
        {
            Library lib = new Library();
            DataTable dtJobHistory = lib.ViewSubmit("aaa", "RNV", "empcode");

            if (dtJobHistory.Rows.Count > 0)
            {
                grdJobHistory.PageIndex = e.NewPageIndex;
                grdJobHistory.DataSource = dtJobHistory;
                grdJobHistory.DataBind();
            }
            else
            {
                lblNoRecordFound.CssClass = "Fail";
                lblNoRecordFound.Text = "no data";
                lnkPrint.Visible = false;
            }
        }

        
    }

推荐答案

亲爱的,

试试这个:

Dear,

try this:

if (dtJobHistory.Rows.Count > 0)
  {
     e.Cancel=true;
     grdJobHistory.DataSource = dtJobHistory;
     grdJobHistory.DataBind();
     grdJobHistory.PageIndex = e.NewPageIndex;
  }



谢谢



Thanks


我建​​议将所有代码移至业务对象并使用
ObjectDataSource作为您的gridview数据源.
分页并不是一件容易的事,但是在后面的代码中手动绑定通常会更好.另外,您将获得代码重用! :)
I would suggest moving all your code to a business object and use
ObjectDataSource as your data source for the gridview.
Paging won''t be easy, but it usually works much better the manually binding in the code behind. Plus, you gain code re-use! :)


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

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