在我的頁面中,當我調用searchBtn_Click時,只有當選擇沒有改變時,selectedvalue纔會被帶入變量ind。因此,如果用戶選擇汽車,然後單擊搜索按鈕,然後他們將選擇更改爲政府,它會刷新頁面,並顯示汽車,我在回發中丟失的東西或在這裏做錯了什麼?DropDownList SelectedValue不會更改
protected void Page_Load(object sender, EventArgs e)
{
string industry = "";
if (Request.QueryString["ind"] != null)
{
industry = Request.QueryString["ind"].ToString();
if (industry != "")
{
indLabel.Text = "Industry: " + industry;
IndustryDropDownList.SelectedValue = industry;
}
}
}
protected void searchBtn_Click(object sender, EventArgs e)
{
string ind = IndustryDropDownList.SelectedValue;
Response.Redirect("Default.aspx?ind=" + ind);
}
IndustryDropDownList的autopostback屬性是否設置爲true? – hungryMind