Click here to Skip to main content
15,915,336 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
protected void grdFarmerList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            BindFarmerList();
            grdFarmerList.PageIndex = e.NewPageIndex;
            grdFarmerList.DataBind();
        }


  private void BindFarmerList()
        {
            try
            {
                dt = new DataTable();
dt = dal.DAL_GetFarmerRegistration_ByOrigin_ApproverID(originname, "", "farmerdata","farmerctscode");
                if (dt.Rows.Count > 0)
                {
                    grdFarmerList.DataSource = dt;
                    grdFarmerList.DataBind();
                }
            else
                  {
                      grdFarmerList.DataSource = dt;
                      grdFarmerList.DataBind();
                      grdFarmerList.EmptyDataText = "No Record Found";
                  }

            }
            catch (Exception ex)
            {
            }
      }


  public DataTable DAL_GetFarmerRegistration_ByOrigin_ApproverID(string originname, string approveheadid, string mastertype,string farmerctscode)
        {
            dataTable = new DataTable();
            try
            {
                sqlConnection = new SqlConnection(connStr);
                openConnection();
                sqlCommand = new SqlCommand();
                sqlCommand.Connection = sqlConnection;
         sqlCommand.CommandText = "sp_get_farmerregistration_by_origin_approveheadid";
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.AddWithValue("@originname", originname);
                sqlCommand.Parameters.AddWithValue("@approveheadid", approveheadid);
                sqlCommand.Parameters.AddWithValue("@mastertype", mastertype);
                sqlCommand.Parameters.AddWithValue("@farmerctscode", farmerctscode);
                sqlDataAdapter = new SqlDataAdapter(sqlCommand);
                sqlDataAdapter.Fill(dataTable);
            }
            catch (Exception ex)
            {
            }
            return dataTable;
        }

totally 10 records is there in database.

i have gridveiw, in that girdview paging is there, when i click first page five record shown and but when i click the second page next 5 record is not shown.

it shows the message No record found.


what is the mistake in my above code.

What I have tried:

as above
Posted
Updated 15-May-18 1:42am
v2
Comments
CHill60 15-May-18 7:44am    
Firstly, your code is "swallowing" any errors. Get rid of the try-catch or put something meaningful in
            catch (Exception ex)
            {
            }
Secondly, we can't tell what is wrong with the code doing the fetching because you haven't shared it with us
[no name] 15-May-18 11:03am    
Are you sure you are not getting any data bind to grid control. You bind data and then assigning EmptyDateText.

Debug and see what is causing this issue as your query seems to be same.

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