Users Pricing

forum

Home Forums Asynchronously populate gridview on button click – MindStick

Asynchronously populate gridview on button click

Anonymous User 3041 13 May 2013
Hi Expert! 

I would like to populate a Gridview which is inside an update panel on button click. Currently the gridview is getting populated however doesn't show up on screen. How to achive it? My line of code as following. 

  public delegate void BindGrid_Delegate();
  protected void btnSearch_Click(object sender, EventArgs e)
  {
        try
        {
            // databind of all the controls
            BindGrid_Delegate bd = new  BindGrid_Delegate(BindGrid);
            IAsyncResult ar = bd.BeginInvoke(null, null); //invoking the method
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PageException", "alert('" + ex.Message + "');", true);
        }
  }

  private void BindGrid()
  {
      try
      {
          DataSet ResultDataSet = GetData();
          gvShowResult.DataSource = ResultDataSet; 
          gvShowResult.DataBind();
          UpdatePanel2.Update();
      }
      catch (Exception ex)
      {
          ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PageException", "alert('" + ex.Message + "');", true);
      }
  }

Updatemode for updatepanel is conditional.

Thanks in advance!
Any help will be appreciated. 



1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md