Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Xform form and custom file upload - how to store in database?


I created a custom page type that is a mix of using a regular xform created in Edit mode, and I have added a custom file upload tool at the top of the page. I added a custom button submit, and on submit it stores the xform data using:


I've stored the file names uploaded into an array. How do I also add these files names (not actual files, just names) into the database? I'm not sure how I append to the database fields stored using ChannelOptions.

Oct 20, 2009 16:22


Try attaching to the BeforeSubmittingPostedData event for your XFormControl instance and set your file upload values direcly to the e.FormData object in your event arguments. Here´s a sample from the sdk:

e.FormData.SetValue("mycustomvalue", "12345");
Linus Ekström
EPiServer Development Team
Oct 20, 2009 20:26

Thanks Linus!

I saw this in the SDK:

XForm form = new XForm();
XFormData data = form.CreateFormData();
NameValueCollection values = data.GetValues();
foreach(String key in values)
data.SetValue(key, "abc");
data.ChannelOptions = ChannelOptions.Database;
data.Send(); // In 4.51 you have to call data.Send(data.FormId);



But I didn't see anything about e.FormData.SetValue. I couldn't figure out how to add to the same form instead of a new form created.

Oct 20, 2009 21:01
Oh that worked by the way, if I didn't say that earlier Laughing
Oct 20, 2009 21:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.