IT Community - Software Programming, Web Development and Technical Support

Inserting value to dropdownlistbox

This is a discussion on Inserting value to dropdownlistbox within the ASP and ASP.NET Programming forums, part of the Web Development category; Hello, I want to know how to add a text and a value for that text in the dropdownlistbox in ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-14-2008, 11:11 PM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Smile Inserting value to dropdownlistbox

Hello,

I want to know how to add a text and a value for that text in the dropdownlistbox in the dropdownbox's text and value property using code.

Example:

The dropdownlistbox will show the list of student names in the text and its value as their regno.
-Kirubha

Last edited by Kirubhananth : 02-14-2008 at 11:16 PM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-18-2008, 07:19 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: Inserting value to dropdownlistbox

u can add like


MyDropDownList.Items.Add(new ListItem("Selecy Country", ""));
MyDropDownList.Items.Add(new ListItem("India", "IND"));
MyDropDownList.Items.Add(new ListItem("United Kingdom", "UK"));
MyDropDownList.Items.Add(new ListItem("United States", "US"));
MyDropDownList.Items.Add(new ListItem("France", "FR"));
MyDropDownList.Items.Add(new ListItem("Srilanka", "SR"));
DropDownList.Items.Add(new ListItem("Selecy City", ""));
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-22-2008, 10:40 PM
poornima poornima is offline
D-Web Sr.Programmer
 
Join Date: Dec 2007
Posts: 189
poornima is on a distinguished road
Smile Re: Inserting value to dropdownlistbox

Hi,
Using the above code u can add data dynamically.
If u want to add the static values use the following in aspx page itself,

<asp: DropDownList id="drop1" runat="server">
<asp :ListItem Text="C++" value="C++"/>
<asp :ListItem Text="Java" value="Java"/>
</asp: DropDownList>

Last edited by poornima : 02-22-2008 at 10:42 PM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-24-2008, 09:44 PM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Smile Re: Inserting value to dropdownlistbox

Thank you fro your timely help madam.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
inserting into table ramesh123 ASP and ASP.NET Programming 1 02-14-2008 08:31 PM
Inserting An Array Into A Database using PHP Sabari PHP Programming 3 12-18-2007 06:37 AM
DetailsView, inserting data from dropdown Anandavinayagam ASP and ASP.NET Programming 5 12-06-2007 10:14 PM
example of Inserting and Retrieving data from xml file hanusoft ASP and ASP.NET Programming 1 11-12-2007 05:13 AM


All times are GMT -7. The time now is 07:27 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0