Hi Dave,
The easiest way is to add a PlaceHolder control to your page. Then, create
the dropdownlist on the fly, add the items to the ddl from the database and
finally add the ddl to the PlaceHolder. Here's the idea:
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub DropDownList1_S electedIndexCha nged _
(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles DropDownList1.S electedIndexCha nged
Dim ddlData As New DropDownList
Dim dt As DataTable
Dim lstItem As ListItem
Dim dr As DataRow
dt = CreateDataSourc e()
For Each dr In dt.Rows
lstItem = New ListItem
lstItem.Text = dr.Item("String Value")
lstItem.Value = dr.Item("Intege rValue")
ddlData.Items.A dd(lstItem)
Next
PlaceHolder1.Co ntrols.Add(ddlD ata)
End Sub
Function CreateDataSourc e() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add( New DataColumn("Int egerValue", GetType(Int32)) )
dt.Columns.Add( New DataColumn("Str ingValue", GetType(String) ))
dt.Columns.Add( New DataColumn("Cur rencyValue", GetType(Double) ))
dt.Columns.Add( New DataColumn("Boo lean", GetType(Boolean )))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSour ce
<form id="Form1" method="post" runat="server">
<P>
<asp:DropDownLi st id="DropDownLis t1" runat="server" AutoPostBack="T rue">
<asp:ListItem Value="--Select--">--Select--</asp:ListItem>
<asp:ListItem Value="Items">I tems</asp:ListItem>
<asp:ListItem Value="Colours" >Colours</asp:ListItem>
</asp:DropDownLis t></P>
<P>
<asp:PlaceHolde r id="PlaceHolder 1" runat="server"> </asp:PlaceHolder ></P>
</form>
Does this help?
Ken
Microsoft MVP [ASP.NET]
Toronto
"DaveF" <df*****@geodec isions.com> wrote in message
news:Ob******** ******@tk2msftn gp13.phx.gbl...
When I select the first dropdownlist box, I need to be able to make
several
dropdownlist boxes on the fly and populate them from the database. Is this
possible? If so, HOW?
--
David Fetrow
Helixpoint LLC.
da***@helixpoin t.com