title: Refresh GridView After Data is Deleted From DetailView Using C#
body: <p>When user select any record from the GridView then my DetailView is updated based on the selection of the GridView.  So what I am trying to do is that when I delete anything from the DetailView then I want to refresh the GridView so basically I don’t want to show still the deleted record in the GridView.  I have tried to resolve this issue by doing the data bind after my connection and SQL statement but it does not refresh it.  One thing to note is that I am using a Accordion pane but both my gridview and the detailview are on the same pane.  I am not sure if this is breaking anything.  Here is my code:</p>
  
  <pre><code>protected void Refresh_ItemCommand(object sender, DetailsViewCommandEventArgs e)
      {
          if (e.CommandName.Equals("Delete", StringComparison.CurrentCultureIgnoreCase))
          {
  
              SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);
              SqlDataAdapter da = new SqlDataAdapter("select ID, Name, Address from dbo.MyTable", con);
              DataTable dt = new DataTable();
              da.Fill(dt);
              Gridview1.DataSource = dt;
              Gridview1.DataBind();
          }
  
      }
  </code></pre>