Listbox selectedIndexChanged does not work when an item is selected from a list

I have a list to fill out with directories. I have successfully populated the list using Directories, but my problem is that I cannot get the selected item value. I set a breakpoint on the SelectedIndexChanged event, but my web application did not seem to miss this code.

Here is my code to populate the list:

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

This is how I get the value from the list in the SelectedIndexChanged event:

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

Am I doing something wrong here? Thanks for the help!:)

+3
source share
1 answer

Use this property: -

AutoPostBack="True"

By default it is False.

+9
source

All Articles