在我的页面中,当我调用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