forum

Home / DeveloperSection / Forums / Asynchronously populate gridview on button click

Asynchronously populate gridview on button click

Anonymous User266213-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. 



Updated on 13-May-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By