Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 21st, 2014, 08:33 AM
Authorized User
Points: 265, Level: 5
Points: 265, Level: 5 Points: 265, Level: 5 Points: 265, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2010
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to add Items in Dropdown list programatically ??

Hi,
There is two dropdown list on page. One is for State and second one is for City related to that sate only.
I have addded the Name of state in first dropdownlist and would like to write programming in such a way so
that when I select the name of state the city related to that state adds automatically in second dropdownlist.

I tried many code but all are giving error.
like

protected void State_DropDownList_SelectedIndexChanged(object sender, EventArgs e)

{
if (State_DropDownList.SelectedItem.Text == "Bihar")
{
City_DropDownList.Items.Add("Patna");
City_DropDownList.Items.Add("Gaya");
City_DropDownList.Items.Add("Aurangabad");
}
}




protected void State_DropDownList_TextChanged(object sender, EventArgs e)
{

if (State_DropDownList.SelectedItem.Text == "Bihar")
{
City_DropDownList.Items.Add("Patna");
City_DropDownList.Items.Add("Gaya");
City_DropDownList.Items.Add("Aurangabad");
}
Post back is enable for both Dropdown list

but these codes are not working please help me.
I do not want to use database for that.
Reply With Quote
  #2 (permalink)  
Old September 21st, 2014, 08:55 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Since this is not related to my book directly, please post this in the General ASP.NET category here: http://p2p.wrox.com/asp-net-4-general-discussion-561/

If you post there, be sure to post the full code for the page as currently it's hard to see why this wouldn't work.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


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
Add to Hyperlink Grid View cell programatically AlexW ASP.NET 4 General Discussion 0 December 31st, 2011 06:19 AM
Issues trying to add code programatically Rowin_aboat Excel VBA 0 November 16th, 2010 11:35 AM
adding Dropdown list Items from SQLSERVER 2005 database biswa Pro VB Databases 1 October 23rd, 2009 10:46 AM
How to add a site programatically millerthegorilla SharePoint Development 1 June 17th, 2008 11:43 AM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM



All times are GMT -4. The time now is 10:50 PM.


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