Microsoft KB Archive/239577

= How To Manually Populate a Listbox Design-Time Control at Run Time =

Article ID: 239577

Article Last Modified on 7/2/2004

-

APPLIES TO


 * Microsoft Visual InterDev 6.0 Standard Edition

-



This article was previously published under Q239577



SUMMARY
By default, the Listbox Design-Time Control (DTC) is designed to pull data from a data source or have its options statically defined in the Listbox DTC properties. This article describes how to dynamically populate the Listbox at run time.



MORE INFORMATION
Use the following steps to dynamically populate the options of Listbox1 at run time.  Add a Listbox DTC to your page and name it Listbox1.  Add the following Visual Basic Scripting Edition (VBScript) code to your page:  Sub populatelistbox Dim mylist(2) mylist(0) = "First Option" mylist(1) = "Second Option" mylist(2) = "Third Option" For i = 0 to UBound(mylist) Listbox1.addItem mylist(i), mylist(i) Next End Sub  Alternatively, add the following JScript code to your page:  function populatelistbox {   var mylist = new Array; mylist[0] = "First Option"; mylist[1] = "Second Option"; mylist[2] = "Third Option"; for (var i = 0;i   Finally, call the function within the ASP code of your page and before the Listbox DTC: <%populatelistbox%> 

Keywords: kbhowto kbctrl KB239577

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.