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

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: avnrao (avn_at_newsgroups.com)
Date: 06/24/04


Date: Thu, 24 Jun 2004 19:19:00 +0530

default DropDownList doesnt support this.
you can write your custom control to do this which just writes out the
required html.

you can see the difficulty to implement it in DropDownList here
http://weblogs.asp.net/asmith/archive/2003/09/30/29846.aspx

Av.
"EEEdiot" <EEEdiot@hotmail.com> wrote in message
news:ic6dnVlfwpAtd0TdRVn2hA@giganews.com...
> 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
>
>