title: Why does the GridView disappear after a button click
body: <pre><code>&lt;asp:UpdatePanel ID="upExec" runat="server" ClientIDMode="Static" UpdateMode="Conditional"&gt;
      &lt;ContentTemplate&gt;
          &lt;button type="button" runat="server" id="btnExec" onserverclick="btnExec_Click" class="btnAll btnExec"&gt;Execute SQL Job&lt;/button&gt;
          &lt;asp:Label ID="lblEMsg" runat="server" ClientIDMode="Static" Text=""&gt;&lt;/asp:Label&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  &lt;asp:UpdatePanel ID="upGV" runat="server" ClientIDMode="Static" UpdateMode="Conditional"&gt;
      &lt;ContentTemplate&gt;
          &lt;asp:GridView EmptyDataText="No Provider Exists" ID="gvData" runat="server" ClientIDMode="Static" AutoGenerateColumns="false"&gt;
              &lt;Columns&gt;
                  &lt;asp:BoundField HeaderStyle-Width="5%" DataField="Name" HeaderText="Name" /&gt;
                  &lt;asp:BoundField HeaderStyle-Width="5%" DataField="ID" HeaderText="ID" /&gt;
              &lt;/Columns&gt;
          &lt;/asp:GridView&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  
  if (!Page.IsPostBack)
  {
      ViewState["sortOrder"] = "Asc";
      ViewState["sortExp"] = "Due Date";
      ShowGridView("Name", "Asc");
  }
  
  public void ShowGridView(string sortExp, string sortDir)
  {
      using (SqlConnection sc = new SqlConnection(gloString))
      {
          try
          {
              sc.Open();
              SqlDataAdapter sda = new SqlDataAdapter(strQuery, sc);
  
              DataSet ds = new DataSet();
              sda.Fill(ds);
  
              DataView dv = new DataView();
              dv = ds.Tables[0].DefaultView;
  
              gvData.DataSource = dv;
              gvData.DataBind();
          }
          catch (SqlException)
          {
          }
          finally
          {
              sc.Close();
          }
      }
      upGV.Update();
  }
  
  public void btnExec_Click(object sender, EventArgs e)
  {
      using (SqlConnection sc = new SqlConnection(gloString))
      {
          try
          {
              sc.Open();
              using (SqlCommand scd = new SqlCommand())
              {
                  scd.CommandText = "MySP";
                  scd.CommandType = CommandType.StoredProcedure;
                  scd.Connection = sc;
  
                  scd.ExecuteNonQuery();
              }
          }
          catch (SqlException)
          {
          }
          finally
          {
              sc.Close();
          }
      }
  
      using (SqlConnection sc = new SqlConnection(floString))
      {
          try
          {
              sc.Open();
              SqlCommand scd = new SqlCommand();
              scd.CommandType = CommandType.StoredProcedure;
              scd.Connection = sc;
              scd.CommandText = "msdb.dbo.sp_start_job";
              scd.Parameters.AddWithValue("@job_name", "JobName");
  
              using (scd)
              {
                  scd.ExecuteNonQuery();
                  ShowGridView("Name", "Asc");
              }
          }
          catch (SqlException)
          {
          }
          finally
          {
              sc.Close();
          }
      }
  
      upExec.Update();
  }
  </code></pre>
  
  <p>When the page first loads, I can see the GridView. When I click the <code>btnExec</code>, the GridView disappears and it displays "No Provider Exists". When I check the source of the page the data is still there.</p>
  
  <p>How can I resolve it so when the button is clicked, it performs the stored procedure and reloads the GridView with the new data.</p>