.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Populating the DropDown List !
 

Populating the DropDown List !

Hi Friends,

I am creating one page in which I have 2 dropdown list boxes. I should populate the second Dropdown based on the text selected in the first dropdown box. So for this what is the technique I should use. please help me out in this.

Thank you,

DotNetMate.

dotnetmate
Code Block

private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string selectedItem = ListBox1.SelectedItem.Text;
//Populate ListBox2
}




You'd want to hook the SelectedIndexChanged event of ListBox1 and then populate ListBox2 based off of the SelectedItem of ListBox1. You need to make sure that AutoPostBack is set to true for ListBox1.
BigTuna99
Code Block

private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string selectedItem = ListBox1.SelectedItem.Text;
//Populate ListBox2
}




You'd want to hook the SelectedIndexChanged event of ListBox1 and then populate ListBox2 based off of the SelectedItem of ListBox1. You need to make sure that AutoPostBack is set to true for ListBox1.
BigTuna99

Hi dotnetmate,

Next time if you got a problem about ASP.net, Recommend posting the question on the forum http://forums.asp.net, there ASP.NET experts can give you satisfying answers.

Thanks!

Feng Chen

You can use google to search for other answers

Custom Search

More Threads

• Unable to retrieve the decryption key C# service x.509
• Login WebControls
• .NET 2 assemblies reflecting on .NET 3.5 assemblies
• Common BCL and Interfaces *.cd files
• Redistributing the .NET framework SDK
• Getting attached event of an object at run time
• Dos shortname is not working on some computers
• can we access the app.config file outside the application folder
• C# and C++ Hooks
• Disable control, but still respond to mouse events?