【问题标题】:PageIndexChanging Event in search button in asp.net?asp.net中搜索按钮中的PageIndexChanging事件?
【发布时间】:2014-02-14 09:09:39
【问题描述】:
 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 条记录,当时页面索引不起作用。它在单击搜索按钮之前调用第一个网格..如何更改我的代码请帮助我.....

【问题讨论】:

  • 它显示了带有一些列的网格视图.....比如日期、速率等......

标签: asp.net sql-server c#-4.0 page-index-changed


【解决方案1】:

试试这个...

    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() 方法中是否有任何搜索文本,例如...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-07
    • 1970-01-01
    • 2011-07-30
    • 1970-01-01
    • 2010-12-03
    • 2014-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多