populate list box from c# block?
Good day,
I have a display form with a list box of id ListBox1, I am trying to populate the list with keys/values retrieved from an external web service (manipulated in a C# block), this is what i have done so far:
1) created a global generic list (FlowChart scope) of type Geocortex.Forms.Client.DataItem (itemsList)
2)in C# block where iItemsList represents variable created in step 1:
iItemsList = new List<Geocortex.Forms.Client.DataItem>();
Geocortex.Forms.Client.DataItem item = new Geocortex.Forms.Client.DataItem();
item.Display = "1";
item.Value = "1";
iItemsList.Add(item);
3)in listbox runtime modifications block, i created an assign block with:
to: form.Find(Of ListBoxFormItem)("ListBox1").DataItems
value: itemsList
two main problems:
1)the C# block is throwing member is not marked as serializable error
2)the runtime modifications block is throwing a type casting error
I am not sure about the correct way to do this & i cannot find a clear reference in the documentation, please advice.
-
Hi Sandeep,
1. The serializable error you are getting in the C# Script activity is from the line iItemsList.Add(item). For whatever reason, this method can't be called from within the script. However, I was able to get it to work by using Assign and InvokeMethod activities that perform the same steps in sequence.
2. The DataItems property of a ListBox is read-only, so you will not be able to set this to a new list of dataitems within the runtime modifications. That is why you are getting the second error there. However, you can assign the itemsList that was created in the previous steps directly to the ListBox1 Input Data property in the body of the form:
/customer/servlet/servlet.FileDownload?file=00P6000000elzqxEAA
You can download the working Workflow (https://data.latitudegeo.com/community/listbox.zip) here .
-Victoria
0 -
Victoria,
Would you please upload your codes again since I have simliar issue? The original link was removed somehow. Thanks a lot !0 -
Hello Hua,
You can now find the code here: https://data.latitudegeo.com/community/listbox.zip
Enjoy!
Pandora0
Please sign in to leave a comment.
Comments
3 comments