Posted on: 10/25/2013 8:42:37 PM | Views : 610

I want to select an item which is a foldername and then all filenames under that folder will display automatically in a listbox. My code is here. it does not work unless I have a button clicked which may does nothing. Is there a way to automatically populate the files after dropdownlist is selected using C# in ASP?
Thanks.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string folderName = DropDownList1.SelectedValue.ToString(); string path = @"\\temp\" + folderName + "\\"; try { if (DropDownList1.SelectedItem.ToString() != "") { DirectoryInfo dirInfo = new DirectoryInfo(path); FileInfo[] files = dirInfo.GetFiles(); ListBox1.Items.Clear(); foreach (FileInfo file in files) { ListBox1.Items.Add(file.ToString()); } ListBox1.Visible = true; } else { ListBox1.Items.Clear(); ListBox1 ...

Go to the complete details ...