Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 10th, 2009, 10:01 PM
Authorized User
 
Join Date: Dec 2007
Location: , , Vietnam.
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Post dropdownlist

Hello everyone
Please guide me how to create dropdownlist when i want it show 3 dropdownlist
EX.
I input the number 3 into textbox.
and then it show 3 dropdownlist.
that mean amount of dropdownlist depending on the number on textbox.
Thanks
Regards
Phuc Hoang
  #2 (permalink)  
Old March 10th, 2009, 10:53 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Depends. Do you want to do this client side or server side? Is there a button involved or is this some sort of AJAX that is fired off when the Textbox value changes?

Since you posted in the ASP.NET forum I will assume you want to do this server side so some code like the following would work:

csharp Code:
for(int i = 0; i < Convert.ToInt32(textBox1.Text); i++)
{
  ListItem item = new ListItem("someText", "someValue");
  DropDownList1.Items.Add(item);
}

Obviously there is no error checking in this code to check to make sure that a whole number was passed in and not, say, a string but you should get the idea.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
  #3 (permalink)  
Old March 11th, 2009, 04:40 AM
Authorized User
 
Join Date: Dec 2007
Location: , , Vietnam.
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Post

Quote:
Originally Posted by dparsons View Post
Depends. Do you want to do this client side or server side? Is there a button involved or is this some sort of AJAX that is fired off when the Textbox value changes?

Since you posted in the ASP.NET forum I will assume you want to do this server side so some code like the following would work:

csharp Code:
for(int i = 0; i < Convert.ToInt32(textBox1.Text); i++)
{
  ListItem item = new ListItem("someText", "someValue");
  DropDownList1.Items.Add(item);
}

Obviously there is no error checking in this code to check to make sure that a whole number was passed in and not, say, a string but you should get the idea.

hth.
-Doug
Thanks so much for helping me to do that
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdownlist sumith ASP.NET 1.0 and 1.1 Professional 1 February 23rd, 2007 09:11 AM
DropdownList Venkatesan ASP.NET 1.0 and 1.1 Basics 1 December 11th, 2006 11:03 AM
how to get value from dropdownlist vandat ASP.NET 1.0 and 1.1 Basics 3 November 28th, 2005 12:47 AM
DropDownList chiraagb VS.NET 2002/2003 5 June 15th, 2004 03:12 AM



All times are GMT -4. The time now is 08:27 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.