[英]How to display in my view the folders corresponding to my selection in a DropDownList?
[英]Display dropdownlist selection with a label
我有一點時間我想要的就是這個。
label.text = dropdownlist.text
如何使用Visual Studio設計器中填充了數據源的下拉列表來完成此操作?
我有一個從dropdownlist.text獲取參數值的更新語句,為什么我不能以同樣的方式設置標簽的text屬性? 我想我錯過了一些非常簡單但我找不到的東西。
<asp:DropDownList ID="ddlEditFruit" style="Z-INDEX: 159;
LEFT:780px; POSITION: absolute; TOP: 280px;"
runat="server" DataSourceID="update"
DataTextField="fruit_id" DataValueField="fruit_id"
AppendDataBoundItems="True" AutoPostBack="True">
<asp:ListItem Selected ="True" Text="" Value ="">(Select)</asp:ListItem>
</asp:DropDownList>
private void btnUpdate_Click(object sender, System.EventArgs e)
{
if (bxStarch.Text.Trim().Length == 0)
{
this.lblError.Visible = true;
}
else
{
this.lblError.Visible = false;
//string id = ddlEditFruit.SelectedValue.ToString();
this.lblId.Visible = true;
this.lblId.Text = ddlEditFruit.SelectedItem.Text;
edit_fruit();
reset_dropdowns();
resest_dropdowns_2();
fill_grd_fruit_id();
fill_grd_size();
fill_grd_progress();
SetFocus(ddlGrade);
change_back();
}
}
在你的代碼隱藏中,試試這個:
label.Text = dropdownlist.SelectedItem.Text
SelectedItem
會將標簽文本放到某些文本中,例如“John”
SelectedValue
會將標簽文本設置為某個值,例如“5”。
您可以嘗試使用DropDownList
的SelectedValue
:
label.Text = dropdownlist.SelectedValue;
label.Text = dropdownlist.SelectedValue
會這樣做:)
我自己修好了。 我試圖在錯誤的點擊事件中更改標簽值。 愚蠢的錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.