Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2014, 08:33 AM
Authorized User
 
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.
 
Old September 21st, 2014, 08:55 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!





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





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