1
 protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack) 
    {

        grid();


    }
   } 

  protected void btnsearch_Click(object sender, EventArgs e)
{

        objRetailPL.ZoneName = ddlzone.SelectedValue;


        //IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true);
        //String datetime = txtdate.Text.ToString();
        //DateTime dt = DateTime.Parse(datetime, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);

        //objRetailPL.date =dt;
        DataTable dtsearch = new DataTable();
        dtsearch = objRetailBAL.searchzone(objRetailPL);
        GVRate.DataSource = dtsearch;
        GVRate.DataBind();



}
   protected void GVRate_PageIndexChanging(object sender, GridViewPageEventArgs e)
  {
  try
  {
      GVRate.PageIndex = e.NewPageIndex;
      grid();

  }
  catch (Exception ex)
  {         

  }
 }

我有用于搜索记录的代码。对于那个网格,我添加了页面索引,但它没有正确出现。当单击搜索按钮时,它显示更多 n 条记录,当时页面索引不起作用。它在单击搜索按钮之前调用第一个网格..如何更改我的代码请帮助我.....

4

1 回答 1

0

尝试这个 ...

    private void grid()
   {
      if(!string.IsNullOrEmpty(yourSearchTextBox.Text)
      {
      // Then call search method. Make sure you bind the Grid in that method.
      }
      else
      {
      // Normally Bind the Grid as you are already doing in this method.
      }
   }

您必须检查该 grid() 方法中是否有任何搜索文本,例如...

于 2014-02-14T10:25:55.183 回答