473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
Nov 18 '05 #1
2 3536
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/archiv.../30/29846.aspx

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

Nov 18 '05 #2
At least, I know.

"avnrao" <av*@newsgroups.com> wrote in message
news:Ou**************@TK2MSFTNGP11.phx.gbl...
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/archiv.../30/29846.aspx

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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
4
by: theo | last post by:
Program flow...load file,then extract the xml text tags from the file,then the number of Xml tags retrieved from the file determines the number of dropdownlist controls instanciated in the...
1
by: Reza Solouki | last post by:
Hello, I have a dropdown list control, where there are cases that I need to populate the control from a database and select one of the items in this list after. Because the content of this...
1
by: C Downey | last post by:
I have a registration form that should load different web user controls based on the selection of a dropdown list. Basically, the user follows the following steps: 1. user comes to very basic...
0
by: Tobin | last post by:
I am new to ASP.NET 2.0 and am redesigning some web pages developed in classic ASP. A common task was for me to accept input of text boxes and date controls to provide a filtered list for the...
1
by: justin | last post by:
I am trying to make a page that has a drop down list at the top, and based upon the selection in the drop down list, inserts a FormView in the bottom of the page. I tried to create each of my...
0
by: swapnil1987 | last post by:
hello friends i am trying to find solution for this problem if u know something then please tell i am creating web application that runs on black berry. here i need to create selection list...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.