how to delete using checkbox in asp repeater control with button?
<p>hi can some one help me please. My objective is to allow users to delete multiple rows in the data base called 'messages'. </p>

<p>By selecting the checkboxes user will be able to delete multiple rows after pressing the button. </p>

<p>However nothing happen when i use the codes below. Can some one help me see if there is anything wrong with my codes? Thanks =) </p>

<p>source code</p>

<pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/MainMasterPage.master" AutoEventWireup="true" CodeFile="Messages.aspx.cs" Inherits="Messages" %&gt;
&lt;%@ Import Namespace="System.Data" %&gt;
&lt;%@ Import Namespace="System.Data.SqlClient" %&gt;

&lt;asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"&gt;

&lt;SCRIPT runat="server"&gt;
private void Page_Load(object sender, System.EventArgs e)
{
    String userLog = Session["loginuser"].ToString();
    if (!IsPostBack)
    {
        LoadData();


    }
}
public void LoadData()
{
String userLog = Session["loginuser"].ToString();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Messages WHERE receiver = '" + userLog + "'",
    "server=19-20\\sqlexpress;database=mpsip;Integrated Security=SSPI");
DataTable table = new DataTable();
adapter.Fill(table);
Repeater1.DataSource = table;
Repeater1.DataBind();

PagedDataSource pds = new PagedDataSource();
pds.DataSource = table.DefaultView;
pds.AllowPaging = true;
pds.PageSize = 10;

int currentPage;

if (Request.QueryString["page"] != null)
{
    currentPage = Int32.Parse(Request.QueryString["page"]);
}
else
{
    currentPage = 1;
}

pds.CurrentPageIndex = currentPage - 1;
Label1.Text = "Page " + currentPage + " of " + pds.PageCount;

if (!pds.IsFirstPage)
{
    linkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (currentPage - 1);
}

if (!pds.IsLastPage)
{
    linkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + (currentPage + 1);
}

Repeater1.DataSource = pds;
Repeater1.DataBind(); 
</code></pre>

<p>}
</p>

<pre><code>    &amp;nbsp;&lt;asp:Repeater ID="Repeater1" runat="server"&gt;

            &lt;itemtemplate&gt;
                &lt;asp:CheckBox ID="CheckBox1" runat="server" /&gt;
          &lt;b&gt;&lt;%# DataBinder.Eval(Container.DataItem, "title") %&gt;&lt;/b&gt;

          &lt;br&gt;From UserID: &lt;%# DataBinder.Eval(Container.DataItem, 
                  "mlogin", "{0:d}") %&gt;
              &lt;br /&gt;
              Date: &lt;%# DataBinder.Eval(Container.DataItem, 
                  "dateandtime", "{0:d}") %&gt;
              &lt;br /&gt;
              MessageID: &lt;%# DataBinder.Eval(Container.DataItem, 
                  "messageID", "{0:d}") %&gt;
                  &lt;br /&gt;


       &lt;/itemtemplate&gt;
       &lt;separatortemplate&gt;
          &lt;hr&gt;
       &lt;/separatortemplate&gt;
        &lt;/asp:Repeater&gt;




        &lt;br /&gt;
        &lt;asp:HyperLink ID="linkPrev" runat="server"&gt;Previous Page&lt;/asp:HyperLink&gt;&amp;nbsp;
        &lt;asp:HyperLink ID="linkNext" runat="server"&gt;Next Page&lt;/asp:HyperLink&gt;

    &lt;br /&gt;
    &lt;asp:Button ID="Button7" runat="server" onclick="Button7_Click" 
    Text="Button" /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;

    &lt;asp:Label ID="Label1" runat="server"&gt;&lt;/asp:Label&gt;
    &lt;br /&gt;
    &lt;asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
        Text="Compose Message" /&gt;
    &lt;asp:Button ID="Button2" runat="server" onclick="Button2_Click" 
        Text="Sent Messages" /&gt;

&lt;/div&gt;
</code></pre>

<p></p>

<pre><code>   protected void Button7_Click(object sender, EventArgs e)
{

    using (SqlConnection conn = new SqlConnection("Data Source=19-20\\sqlexpress;" + "Initial Catalog = mpsip; Integrated Security = SSPI"))
    {
        conn.Open();
        SqlCommand cmdDel = conn.CreateCommand();
        SqlTransaction transaction = conn.BeginTransaction("MyTransaction");
        cmdDel.Connection = conn;
        cmdDel.Transaction = transaction;
        try
        {
            for (int i = 0; i &lt; Repeater1.Items.Count; i++)
            {
                //This assumes data type of messageID is integer, change (int) to the right type
                cmdDel.CommandText = "delete from messages where messageID = '" + ((String)((DataRow)Repeater1.Items[i].DataItem)["messageID"]) + "'";
                cmdDel.ExecuteNonQuery();

                // Continue your code here

            }
            transaction.Commit();
        }
        catch (Exception ex)
        {
            try
            {
                transaction.Rollback();
            }
            catch (Exception ex1)
            {
                //TODO: write log
            }
        }
    }


}
</code></pre>

<p>}</p>
