title: how to use update panel(ajax control) in my page for update gridview?
body: <p>I have a scriptmanager in my master page and , my content page has a gridview and btndelete I want when click btndelete delete selected data and refresh the gridview and btndelete is out of update panel
  I very try but mycode work very bad please help me :((</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
              &lt;ContentTemplate&gt;
          &lt;asp:GridView ID="GridView1"  runat="server"  AutoGenerateColumns="False" BackColor="White"
               BorderColor="Blue" BorderStyle="Solid" CellPadding="3" DataSourceID="SqlDataSource1"
               ForeColor="Black"  GridLines="Vertical" Width="656px"  &gt;
              &lt;AlternatingRowStyle BackColor="#CCCCCC" /&gt;
              &lt;Columns&gt;
                   &lt;asp:TemplateField&gt;
                       &lt;ItemTemplate&gt;
  
                           &lt;asp:CheckBox ID="check1" runat="server" /&gt;
  
                       &lt;/ItemTemplate&gt;
                   &lt;/asp:TemplateField&gt;
                  &lt;asp:BoundField DataField="picname" HeaderText="picname" SortExpression="picname" /&gt;
              &lt;/Columns&gt;
              &lt;FooterStyle BackColor="#CCCCCC" /&gt;
              &lt;HeaderStyle BackColor="#99FF66" Font-Bold="True" ForeColor="Black" BorderColor="#006600" /&gt;
              &lt;PagerStyle BackColor="#33CC33" ForeColor="#0066FF" HorizontalAlign="Center" BorderStyle="Dashed" /&gt;
              &lt;RowStyle BackColor="Lime" /&gt;
              &lt;SelectedRowStyle BackColor="#0066CC" Font-Bold="True" ForeColor="White" /&gt;
              &lt;SortedAscendingCellStyle BackColor="#F1F1F1" /&gt;
              &lt;SortedAscendingHeaderStyle BackColor="#808080" /&gt;
              &lt;SortedDescendingCellStyle BackColor="#CAC9C9" /&gt;
              &lt;SortedDescendingHeaderStyle BackColor="#383838" /&gt;
          &lt;/asp:GridView&gt;
                  &lt;/ContentTemplate&gt;
              &lt;Triggers&gt;
                  &lt;asp:AsyncPostBackTrigger ControlID="btndelete" EventName="Click" /&gt;
              &lt;/Triggers&gt;
  
              &lt;/asp:UpdatePanel&gt;
  &lt;asp:Button ID="btndelete" runat="server" Text="Delete" OnClick="btndelete_Click" /&gt;
  </code></pre>
  
  <p>this is my cs code for btndelete:</p>
  
  <pre><code> protected void btndelete_Click(object sender, EventArgs e)
              {
  
  
                  ArrayList mylist = new ArrayList();
  
                  string id = string.Empty;
                   int j = 0;
                  for (int i = 0; i &lt; GridView1.Rows.Count; i++)
                  {
                      CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("check1");
                      if (cb != null)
                      {
                          if (cb.Checked)
                          {
                              id = GridView1.Rows[i].Cells[1].Text;
                              mylist.Add(id);
                              } 
  
                          }
                      }
                  }
                  delet(mylist);
  }
  
  
       private void delet(ArrayList a) {
                  SqlConnection con2 = new SqlConnection();
                  con2.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["photogaleryConnectionString"].ToString();
                  SqlCommand cmd = new SqlCommand("delete from picture where picname =" + "@picname", con2);
  
  
  
  
                      foreach (string s in a)
                      {
                          cmd.Parameters.AddWithValue("picname", s.ToString());
                          con2.Open();
                          cmd.ExecuteNonQuery();
                          con2.Close();
                      }
  </code></pre>