Click here to Skip to main content
15,742,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:-
C#
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;
            }
        }

        
    }
Posted
Updated 7-May-10 18:37pm
v3

Dear,

try this:

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


Thanks
 
Share this answer
 
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! :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900