Click here to Skip to main content
15,935,259 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
protected void Page_Load(object sender, EventArgs e)
{

drp_cat.Items.Clear();
drp_cat.Text = "choose items";
string[] dirs = Directory.GetDirectories(Request.PhysicalApplicationPath + "Docs");
foreach (string dir in dirs)
{
drp_cat.Items.Add(dir);
}

}

in page load i have written above code. now i want the selected item in the dropdown box which will bring corresponding items and show in list box. but i cant do it. pls help me.
Posted

SelectedItem[^] should give you what you want.
 
Share this answer
 
e.g.: Design DropDownBox & ListBox Control On Your Page.

On Page_Load Event...

if(IsPostBack)
{
string __sDropDownItem = Combo.SelectedValue.ToString();

string __sArray = Directory.GetDirectories(Path.Combine(sYourPath, __sDropDownItem ));

List.Items.Clear();

foreach(string __s in __sArray)
{
List.Items.Add(__s, __s);
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900