title: data getting moved instead of added
body: <p>I am trying to create functionality to copy data from one order to another. Here is the code that copies the data:</p>
  
  <pre><code> protected void copySeminarIDButton_Click(object sender, EventArgs e)
      {
          try
          {
              //show some message incase validation failed and return
              String seminarID = this.copySeminarIDText.Text;
              Int32 id;
              try
              {
                  id = Convert.ToInt32(seminarID);
              } catch (Exception e2)
              {
                  return;
              }
  
              //copy over all the registration types now for the entered id
              using (SeminarGroupEntities db = new SeminarGroupEntities())
              {
                  var seminars = db.seminars.Where(x =&gt; x.id == id);
                  if (seminars.Any())
                  {
                      var s = seminars.First();
  
                      //Load RegTypes
                      try
                      {
                          var regList = s.seminar_registration_type
                              .OrderBy(x =&gt; x.sort)
                              .ToList()
                              .Select(x =&gt; new seminarRegistrationTypeListing
                              {
                                  id = x.id,
                                  amount = x.amount,
                                  description = x.description,
                                  feeTypeId = x.feeTypeId,
                                  method = x.method,
                                  promoCodes = PromoCodesToString(x.xref_reg_type_promo.Select(z =&gt; z.promoId).ToList()),
                                  title = x.title,
                                  isPreorder = x.isPreorder,
                                  sort = x.sort
                              });
  
                          this.dlTypes.DataSource = regList;
                          this.dlTypes.DataBind();
                      }
                      catch (Exception ex)
                      {
                          Response.Write("RegTypes: " + ex.Message);
                      }
                  } else
                  {
                      return;
                  }
              }
          }
          catch (Exception m)
          {
  
          }
      }
  </code></pre>
  
  <p>The user will enter a <code>ID</code> of the invoice they want to copy from. The above code copies pull the right data from the invoice and loads it on the page. When i click save the data is being saved. </p>
  
  <p>The problem that is occurring is that the invoice that i copy data from will no longer have the data any more. So basically instead of copying the data its actually moving the data to the new invoice. I want to copy.</p>
  
  <p>Here is my <code>Save</code> code.</p>
  
  <pre><code>        private void SaveRegTypes(int seminarId)
      {
          //Reg Types
          using (SeminarGroupEntities db = new SeminarGroupEntities())
          {
              try
              {
                  var s = db.seminars.Where(x =&gt; x.id == seminarId).First();
                  var msg = "alert('Saving:" + seminarId + "');";
                  ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Data Copied...", msg, true);
                  this.copySeminarIDText.Text = msg;
  
                  //s.seminar_registration_type.Clear();
                  foreach (DataListItem dli in this.dlTypes.Items)
                  {
                      String sId = ((HiddenField)dli.FindControl("hdnId")).Value;
                      var reg = new seminar_registration_type();
                      if ((sId != "") &amp;&amp; (sId != "0"))
                      {
                          Int32 id = Convert.ToInt32(sId);
                          reg = db.seminar_registration_type.Where(x =&gt; x.id == id).Single();
                          ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Data Copied...", "alert('hidded field id is empty.');", true);
                      }
                      else
                      {
                          db.seminar_registration_type.Add(reg);
                      }
  
                      reg.feeTypeId = Convert.ToInt32(((DropDownList)dli.FindControl("ddlRegType")).SelectedItem.Value);
                      reg.amount = Convert.ToDecimal(((TextBox)dli.FindControl("txtPrice")).Text);
                      reg.title = ((DropDownList)dli.FindControl("ddlRegType")).SelectedItem.Text;
                      reg.description = ((TextBox)dli.FindControl("txtRegDesc")).Text;
                      reg.method = Convert.ToInt32(((DropDownList)dli.FindControl("ddlDeliveryMethod")).Text);
                      reg.promocode = null;
                      reg.isPreorder = Convert.ToBoolean(((CheckBox)dli.FindControl("chkPreorder")).Checked);
                      reg.sort = 1;
                      reg.seminarId = seminarId;
  
                      string sort = ((TextBox)dli.FindControl("txtRTSort")).Text;
                      try
                      {
                          reg.sort = Convert.ToInt32(sort);
                      }
                      catch (Exception ex) { }
  
                      //Do Promo Codes
  
  
                      Repeater rptPromocodes = (Repeater)dli.FindControl("rptPromoCodesList");
                      reg.xref_reg_type_promo.Clear();
                      foreach (RepeaterItem ri in rptPromocodes.Items)
                      {
                          try
                          {
                              Int32 id = Convert.ToInt32(((HiddenField)ri.FindControl("hdnCodeId")).Value);
                              DateTime? expires = null;
  
                              try
                              {
                                  HiddenField exp = (HiddenField)ri.FindControl("hdnExpirationDate");
                                  if (!String.IsNullOrWhiteSpace(exp.Value))
                                      expires = Convert.ToDateTime(((HiddenField)ri.FindControl("hdnExpirationDate")).Value);
                              }
                              catch (Exception ex) { }
  
                              var code = db.promo_code.Where(x =&gt; x.id == id).First();
                              reg.xref_reg_type_promo.Add(new xref_reg_type_promo
                              {
                                  expiration = expires,
                                  promoId = code.id
                              });
                          }
                          catch (Exception ex) { }
                      }
  
                      db.SaveChanges();
                      ((HiddenField)dli.FindControl("hdnId")).Value = reg.id.ToString();
  
                  }
  
              }
              catch (Exception ex) 
              {
                  String err = ex.Message;
              }
          } 
  
      }
  </code></pre>