473,675 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically populating a dropdown list in ASP.Net

10 New Member
Hi,

I have two dropdowns.
I want that the DDL2 gets populated based on the values in DDL1.
How can I achieve that.

This is the way I am populating DDL1

string cmd = "Select * from abc ";
SqlDataAdapter da = new SqlDataAdapter( cmd, connection);

DataSet ds = new DataSet();
da.Fill(ds);
DropDownList1.D ataSource = ds;
DropDownList1.D ataTextField = "Name";
DropDownList1.D ataValueField = "Code";
DropDownList1.D ataBind();
DropDownList1.I tems.Insert(0, "--Select--");
Apr 4 '08 #1
2 1336
kunal pawar
297 Contributor
right, just set property Autopostback=tu re for DDL1 and populate ur DDL2 in selected indexchanged event of DDL1.
to get selected value of DDL1
dropdown1.selec tedItem.value
& for text
dropdown1.selec tedItem.text
Apr 4 '08 #2
Shikha1234
10 New Member
right, just set property Autopostback=tu re for DDL1 and populate ur DDL2 in selected indexchanged event of DDL1.
to get selected value of DDL1
dropdown1.selec tedItem.value
& for text
dropdown1.selec tedItem.text



Hey thanks a ton!
I could achieve this
Apr 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3793
by: Dmitry Korolyov [MVP] | last post by:
Is that possible? In other words, I want a dropdown list (and other list-type controls) which appears in edit more of a templated column to be populated with data at the run time. An attempt to do so results in non-existing object error. (Object reference not set to an instance of an object). -- Dmitry Korolyov MVP: Windows Server - Active Directory
9
7036
by: netasp | last post by:
hi all, how can I populate one aspx form when page is loading based on page ID? for example: loading page A (to search for VB code) would display labels and texboxes, dropdown lists all related to VB, plus the address bar would show something like this: www.somethinghere?id=3 and if you change number 3 from the address bar to (for example) 34 or 71 you would get different page with the same formatting like I.e: www.somethinghere?id=34...
1
1894
by: jeffejohnson | last post by:
I'm looking to see if anyone has experienced this... I've got a dropdown that I'm populating dynamically and the items include HTML special characters (like Ô). If I load them from an existing JavaScript array I don't have any problems, but I'm generating the arrays dynamically, then populating my dropdown dynamically with the onload event. I've tried setting multiple encodings in the meta tag with no success.
0
1691
by: koonda | last post by:
Hi all, I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my SQL statements in the Data Acess Layer to create more secure web service application. The Web service class is also in the Data Access Layer. I need to populates the 4 Dropdown list boxes on the web form from one table. I have Customer table which...
0
8515
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8675
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8717
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7499
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4464
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2120
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1863
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.