CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.

YesSoftware Forums -> Archive -> GotoCode Archive

 Populate listbox with dynamic array

Print topic Send  topic

Author Message
Posted: 12/17/2003, 11:04 AM

I need to know how to populate/change the values in a listbox from an array which was dynamically created just before the page and list box is displayed.
I am using CCS2 with ASP with templates and Access db.

I am trying to set/change the values of a listbox in the record before show event.
- Before attempting to change the listbox values to the array the listbox datasource type I selected was 'List of Values' and I put a couple of values in as temporary values.
- 'NewRecord1' is the name of the record
- 'ListBox2' is the name of the listbox
- 'myArray' is the name of the single dimentional array I am populating with values. These values in this array are being set/created OK. This can be evidenced by Example B code below which takes these values and populates the listbox

My problem is I would like to set the value of the Listbox not knowing how many elements are in the array (because it is going to dynamically vary) so although Example B below works with elements of the array 'myArray' I cannot hard code in each element like Example B shows.

Example A which works to populate my listbox (this code taken right from CCS help and it works but it is hardly dynameic data):
Set NewRecord1.ListBox2.DataSource = CCCreateDataSource(dsListOfValues, Empty, _

Example B which Works which shows the 'myArray' values are in the array:
Set NewRecord1.ListBox2.DataSource = CCCreateDataSource(dsListOfValues, Empty, _
Array(Array(myArray(0), myArray(1), myArray(2), myArray(3)), Array(myArray(0), myArray(1), myArray(2), myArray(3) )))

I am trying to use ASP code instead of JavaScript as ASP code is populating the values of 'myArray' and I thought I was a little more familiar with ASP. Also, CCS help shows an example in ASP but example does not show a dynamic array that was created/populated with an variable number of elements.

Thanks for any examples or help.

Posted: 12/19/2003, 5:25 AM

Thanks to Peter from Yes Software Support for his quick response and correct solution. Solution was simple but embarrassingly not obvious to me till I saw it. I was incorrectlyl prefixing each array with the word Array like this, Array(Array(myArray),Array(myArray) ) which produced an error.

Correct Solution was:
Set NewRecord1.ListBox2.DataSource = CCCreateDataSource(dsListOfValues, Empty, _

myArray1 for the elements
myArray2 for descriptions

Thanks again to Peter and Yes Software Support.



These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

Web Database

Join thousands of Web developers who build Web applications with minimal coding.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.