As usual we are doing some custom contact us forms and this means for various good reasons we have to insert the collected data to the forms for editors structure. So I tried this:
Dynamicweb.Forms.Submit submit = new Dynamicweb.Forms.Submit();
submit.FormID = 16;
submit.Date = DateTime.Now;
submit.Ip = GetUsersIPAddress();
submit.SessionId = HttpContext.Current.Session.SessionID;
submit.PageId = Convert.ToInt32(contactUsUser.PageId);
submit.UserID = 0;
submit.Referrer = HttpContext.Current.Request.ServerVariables["HTTP_REFERER"];
Dynamicweb.Forms.Form frm = submit.Form; // get no set??
foreach (var formFields in frm.Fields)
{
if (formFields.SystemName == "FormMode")
{
submit.FieldValues.Add(new Dynamicweb.Forms.SubmitData() { FieldID = formFields.ID, Fieldname = formFields.Name, Value = contactUsUser.UserRequestMode });
}
if (formFields.SystemName == "Name")
{
submit.FieldValues.Add(new Dynamicweb.Forms.SubmitData() { FieldID = formFields.ID, Fieldname = formFields.Name, Value = contactUsUser.Name });
} .... adding 23 fields ....
}
submit.Save();
This works since I get a good submit added to the database, but no Field data frm.Fields get inserted to the database. The frm.Fields has a getter but no setter on the property. Is there a secret way to do this?
Rgds Kev