简体   繁体   中英

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! :)

Use the property:-

AutoPostBack="True"

By default it is False .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM