簡體   English   中英

從列表中選擇項目時,列表框selectedIndexChanged不會觸發

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

我有一個需要由目錄填充的列表框。 我已成功用目錄填充列表框但我的問題是我無法獲得所選項目的值。 我在SelectedIndexChanged事件上放置了一個斷點,但我的Web應用程序似乎沒有運行該代碼。

這是我填充列表框的代碼:

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

這就是我從SelectedIndexChanged事件的列表框中獲取值的方法:

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

我在這里做錯了嗎? 謝謝您的幫助! :)

使用財產: -

AutoPostBack="True"

默認情況下為False

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM