FormItem Object (Dundas Upload Control 2.0)
Comprises the Form collection, and stores input data for a form element.
Remarks
The FormItem object is used to retrieve data from the POST form.
To use the Upload control the html form which POSTS the data must have an ENCTYPE of "Multipart/Form-Data".
To retrieve data you MUST FIRST CALL either the control's Save method, the SaveToMemory method or the GetNextFile method first so that the Form collection is populated. Once this is done you can retrieve data via the Form collection's FormItem objects.
Note: the Save and SaveToMemory methods will retrieve ALL form data with one method call, unlike the GetNextFile method which retrieves all form data up to the first populated file input box encountered. To retrieve all form data with GetNextFile call GetNextFile until the function returns "Nothing." for sample code demonstrating how to do this see the GetNextFile topic.
To retrieve form items you can specify the name of the form element via its string key (e.g. strVariable = objUpload.Form("txtSomeTextBox")). Note that the string key is actually the TagName property of the FormItem object. Alternatively you can retrieve an element's value by specifying the appropriate numerical index (e.g. strVariable = objupload.Form(0)). To retireve the value you do not have to specify Value.
NOTE: If a form element is left empty by the user then attempting to access the element's data via the Upload control's Form collection will result in a value of "Empty" being returned. To test for an empty form element use the following line of code: "If IsEmpty(objUpload.Form("MyFormElement")) Then ... Else...End If".
To retrieve multiple selections for one form element (e.g. a listbox) use the Count property of the FormItem object (this will have the total number of items selected for the form element). Use a For loop with the Count property of the FormItem object as the upper loop delimiter and call the Value method for each item. For example, to retrieve all selected elements for a multi-item listbox (named "ListBox") you could use the following syntax:
For i = 0 To objUpload.Form("ListBox").Count - 1
Response.Write objUpload.Form("ListBox").Value(i)
Next
Note: alternatively you could use a For ... Each loop to access these multiple selections. To use a For ... Each loop utilize the following syntax:
For Each Item in objUpload.Form
strSomeVariable = objUpload.Form(Item)
Next
See Also: Form Collection | How to Use the Dundas Upload Control