Repeating list after post back form in ASP.NET and C#
<p>I have some code retrieving the files from a folder using ASP.NET and C# and I display them using a CheckBoxList because the user will be able to select one of the files and then with a button at the end the user will have the ability to email that selected item.</p>

<p>The issue I am having is that after the item is selected and the email is sent, the page reloads and the items are duplicated and I am not sure why or how to corrected. Any help will be appreciate it.</p>

<p>The code is as follows:</p>

<pre><code>if (File.Exists(wavFile))
                    {


                        ListItemCollection itemCollection = CheckBoxList2.Items;
                        itemCollection.Add(new ListItem(wavFile));
                        itemCollection.Add(new ListItem("&lt;asp:Panel ID=\"Panel1\" runat=\"server\"&gt;&lt;object id=\"MediaPlayer\" width=\"100\" height=\"42\" classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" standby=\"Loading Windows Media Player components...\"" +
                                          "type=\"application/x-oleobject\"&gt;&lt;param name=\"FileName\" value=\"" + wavFile + "\"&gt;&lt;param name='AUTOPLAY' value='0'&gt;" +
                                          "&lt;embed type=\"application/x-mplayer2\" src=\"" + wavFile + "\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" name=\"MediaPlayer\" uimode=\"none\" width=\"300\" height=\"42\"&gt;" +
                                          "&lt;/embed&gt;&lt;/object&gt;&lt;/asp:Panel&gt;&lt;br/&gt;&lt;br/&gt;"));
</code></pre>

<p>}</p>

<p>And then the email is control by a button with the following code:</p>

<pre><code>protected void btnSend_Click1(object sender, EventArgs e)
    {
        try
        {
            MailMessage mail = new MailMessage();
            mail.To.Add("email@email.com");
            mail.From = new MailAddress("email@email.com");
            mail.Subject = claimNumber.Text;
            mail.Body = "This is a test of the email again.";
            System.Net.Mail.Attachment attachment;
            attachment = new System.Net.Mail.Attachment(CheckBoxList2.SelectedValue);
            mail.Attachments.Add(attachment);
            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.email.com"; //Or Your SMTP Server Address
            smtp.Credentials = new System.Net.NetworkCredential
            ("email@email.com", "pa$$w0rd");

            smtp.EnableSsl = true;
            smtp.Send(mail);

            this.labelSuccessIndex.Text = "&lt;br/&gt;&lt;strong&gt;The file has been emailed.&lt;/strong&gt;";
        }
        catch (Exception ex)
        {
            labelError.Text = ex.Message;
        }
    }
</code></pre>
