473,569 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

binding data to drop down menu

HI,

I have a select menu

<select id="country" runat="server" class="myformat ">

<option value="AFGHANIS TAN">AFGHANISTA N</option>

<option value="ALBANIA" >ALBANIA</option>

<option value="ALGERIA" >ALGERIA</option>

The option value data are all keyed in manually

Right now im doing a edit form.

when the data is retrieve form the db, it will auto bind the value to the
country drop down list.

are there any simple ways to do that?

Pls advise.

Thanks

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Mar 29 '07 #1
3 2143
On Mar 29, 1:04 pm, "Eric Layman" <namyalcire[at no spam]gmail.com>
wrote:
HI,

I have a select menu

<select id="country" runat="server" class="myformat ">

<option value="AFGHANIS TAN">AFGHANISTA N</option>

<option value="ALBANIA" >ALBANIA</option>

<option value="ALGERIA" >ALGERIA</option>

The option value data are all keyed in manually

Right now im doing a edit form.

when the data is retrieve form the db, it will auto bind the value to the
country drop down list.

are there any simple ways to do that?

Pls advise.

Thanks

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Hi Eric,
Try this....
Private Sub loadAndSetDropd own(ByRef pDdl As DropDownList, ByRef
pdt As DataTable, ByVal psSetVal As String)
pDdl.Items.Clea r()
Dim dr As DataRow
Dim lbItem As ListItem
For Each dr In pdt.Rows
lbItem = New ListItem
lbItem.Value = dr("code")
lbItem.Text = dr("descr")
pDdl.Items.Add( lbItem)
If CStr(lbItem.Val ue) = psSetVal Then
pDdl.SelectedVa lue = psSetVal
End If
Next
End Sub
Pass in the dropdown list (in my example, it'd be myDropdown like I
declare it below), the datatable you get back form your webservice/
database connection, and a "set value". This code works w/ an asp
dropdown list (not a plain old HTML dropdown like you have above).
Here's the HTML to declare it
<asp:dropdownli st id=myDropdown runat="server"> </asp:dropdownlis t>
Hope that helps,
Lisa Ashley Rafter

Mar 29 '07 #2

"Lisa Ashley Rafter" <li************ **@yahoo.comwro te in message
news:11******** **************@ o5g2000hsb.goog legroups.com...
On Mar 29, 1:04 pm, "Eric Layman" <namyalcire[at no spam]gmail.com>
wrote:
>HI,

I have a select menu

<select id="country" runat="server" class="myformat ">

<option value="AFGHANIS TAN">AFGHANISTA N</option>

<option value="ALBANIA" >ALBANIA</option>

<option value="ALGERIA" >ALGERIA</option>

The option value data are all keyed in manually

Right now im doing a edit form.

when the data is retrieve form the db, it will auto bind the value to the
country drop down list.

are there any simple ways to do that?

Pls advise.

Thanks

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Hi Eric,
Try this....
Private Sub loadAndSetDropd own(ByRef pDdl As DropDownList, ByRef
pdt As DataTable, ByVal psSetVal As String)
pDdl.Items.Clea r()
Dim dr As DataRow
Dim lbItem As ListItem
For Each dr In pdt.Rows
lbItem = New ListItem
lbItem.Value = dr("code")
lbItem.Text = dr("descr")
pDdl.Items.Add( lbItem)
If CStr(lbItem.Val ue) = psSetVal Then
pDdl.SelectedVa lue = psSetVal
End If
Next
End Sub
Pass in the dropdown list (in my example, it'd be myDropdown like I
declare it below), the datatable you get back form your webservice/
database connection, and a "set value". This code works w/ an asp
dropdown list (not a plain old HTML dropdown like you have above).
Here's the HTML to declare it
<asp:dropdownli st id=myDropdown runat="server"> </asp:dropdownlis t>
Hope that helps,
Lisa Ashley Rafter
Hi Lisa,

Thanks for replying.

But the option values r not drawn from db

by default, the country lits are hand typed.

then when use registers, they choose a country and save the country to a db

right now they they doing editing, it mus also pull out the country they
selected previously.

because the list is hand written; it would be a hideous task to indiviually
compare the db value against the list.....

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Mar 29 '07 #3
On Mar 29, 1:52 pm, "Eric Layman" <namyalcire[at no spam]gmail.com>
wrote:
"LisaAshleyRaft er" <lisaashleyraf. ..@yahoo.comwro te in messagenews:11* *************** ******@o5g2000h sb.googlegroups .com...


On Mar 29, 1:04 pm, "Eric Layman" <namyalcire[at no spam]gmail.com>
wrote:
HI,
I have a select menu
<select id="country" runat="server" class="myformat ">
<option value="AFGHANIS TAN">AFGHANISTA N</option>
<option value="ALBANIA" >ALBANIA</option>
<option value="ALGERIA" >ALGERIA</option>
The option value data are all keyed in manually
Right now im doing a edit form.
when the data is retrieve form the db, it will auto bind the value to the
country drop down list.
are there any simple ways to do that?
Pls advise.
Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Hi Eric,
Try this....
Private Sub loadAndSetDropd own(ByRef pDdl As DropDownList, ByRef
pdt As DataTable, ByVal psSetVal As String)
pDdl.Items.Clea r()
Dim dr As DataRow
Dim lbItem As ListItem
For Each dr In pdt.Rows
lbItem = New ListItem
lbItem.Value = dr("code")
lbItem.Text = dr("descr")
pDdl.Items.Add( lbItem)
If CStr(lbItem.Val ue) = psSetVal Then
pDdl.SelectedVa lue = psSetVal
End If
Next
End Sub
Pass in the dropdown list (in my example, it'd be myDropdown like I
declare it below), the datatable you get back form your webservice/
database connection, and a "set value". This code works w/ an asp
dropdown list (not a plain old HTML dropdown like you have above).
Here's the HTML to declare it
<asp:dropdownli st id=myDropdown runat="server"> </asp:dropdownlis t>
Hope that helps,
LisaAshleyRafte r

HiLisa,

Thanks for replying.

But the option values r not drawn from db

by default, the country lits are hand typed.

then when use registers, they choose a country and save the country to a db

right now they they doing editing, it mus also pull out the country they
selected previously.

because the list is hand written; it would be a hideous task to indiviually
compare the db value against the list.....

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com- Hide quoted text -

- Show quoted text -
Eric ,
You want to find out what country they selected?
Lisa

Mar 29 '07 #4

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

Similar topics

3
2948
by: KK | last post by:
Drop-down menus are the hottest thing since Wonder Bread but . . . 1. Alot of people put them in the they-look-nice-but-you-cant-code-them-right-so-they-always-look-messed-up category (a la "frames"). Do you think this is true> 2. Some people think they take up too much KB. 3. Some people are worried that people who have javascript turned off...
10
3454
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the there is no drop down menu functionality at all. I wanted to implement an alternative stylesheet for IE, but my link to it is apparently broken. What...
0
16151
by: vikram.cvk | last post by:
Hello Experts, Im trying to design a CSS vertical drop down menu which should have the following functionality. Home About Us | -->Overview
2
2558
by: hemanth.singamsetty | last post by:
Hello there, I've a drop down menu (created using CSS & Javascript -- see code below). My problem is, whenever I click a link on the menu the new page replaces the current page (and the menu disappears). Is there a way, I can keep the menu always on top. ( A good example of what I'm looking for is similar to the menu bar in...
4
2647
by: simon.cigoj | last post by:
I have an javascript made menu and some forms with the dropdown element. When the menu opens and scrolls down the drop down is displeyed over the menu and obscures the menu choices. I have this problem only in IE, in firefox it works ok. Is there a solution to this problem? I tried to hide the drop down when the menu opens but sometimes...
5
4212
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
2
2599
by: bmayer | last post by:
I am using a detail view and binding it to a sql data source (at some point in the future it will be an object data source). I have seen the article "Working with Data is ASP.NET 2.0 :: Customizing the Data Modification Interface", and its description of how to turn one of the fields into a template field, then add a drop down list. I want...
0
7352
by: tusaar | last post by:
Hi all I am in big need for a drop down menu created with php, mysql and ajax. Exactly, I need three drop down menu (Category, Subcategory and Item). The data of each drop down will come from Mysql. Anybody can help me please.. I will be very much thankfull. Please help me and give me a proper solution for that ASAP. Thanks Tushar
4
9278
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me if it works, and if it does not, tell me why it does not work. Thanks.
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.