Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listbox selectedIndexChanged doesn't fire when selecting an item from the list

I have a listbox that needs to be populated by directories. i have successfully filled the listbox with the Directories but my problem is i can't get the selected item's value. i placed a breakpoint on the SelectedIndexChanged event but my web application doesn't seem to run through that code.

Here is my code for populating the listbox:

        lstDirectories.DataSource = dtDirectories;
        lstDirectories.DataValueField = "DirectoryID";
        lstDirectories.DataTextField = "DirectoryName";
        lstDirectories.DataBind();

This is how i get value from the listbox on the SelectedIndexChanged Event:

        TextBox1.Text = lstDirectories.SelectedItem.Value.ToString();

am i doing something wrong here? thanks for the help! :)

like image 584
danielle Avatar asked Dec 20 '22 18:12

danielle


1 Answers

Use the property:-

AutoPostBack="True"

By default it is False.

like image 132
Afnan Ahmad Avatar answered Jan 11 '23 22:01

Afnan Ahmad