Dynamically adding content to selection list in ASP.NET / VB.NET

E

EEEdiot

Okay,

I know to add content dynamically to web page file you can have
something like the following and it would add a whole bunch of <option>
items for the <select> list. How do you dynamically add <optgroup> items
and <options> under them?

TIA!

In ASPX file:
<%@ Page Language="VB" inherits="..." Src="... .vb" AutoEventWireup="False"
%>
....
<select style="WIDTH: 155px" id="lst_Currency" runat="server"></select>
....

In VB file:

Imports ...

Public Class ...

Public Sub Page_Load(sender as Object, e as EventArgs) _
Handles MyBase.Load

If Me.IsPostBack = False
lst_Currency.Items.Add(New ListItem("Euros", "0.6075"))
lst_Currency.Items.Add(New ListItem("Japanese Yen",
"79.7894"))
lst_Currency.Items.Add(New ListItem("US Dollars", "0.7344"))
lst_Currency.Items.Add(New ListItem("Lower Slobovian
Dinars", "733.4939"))
End If
End Sub
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top