<asp:DropDownList id="DropDownList3" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged">
<asp:ListItem Value="1">基础建筑</asp:ListItem>
<asp:ListItem Value="2">特殊建筑</asp:ListItem>
<asp:ListItem Value="3">军事建筑</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
//
} protected void Button1_Click(object sender, EventArgs e)
{
DropDownList3.Items[0].Selected = true;
}现在的问题是当我选择DropDownList3后,再点击Button1_Click事件,就会报错,提示"不能绑定多个选项"
请各位帮我看看是什么原因?
<asp:ListItem Value="1">基础建筑</asp:ListItem>
<asp:ListItem Value="2">特殊建筑</asp:ListItem>
<asp:ListItem Value="3">军事建筑</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
//
} protected void Button1_Click(object sender, EventArgs e)
{
DropDownList3.Items[0].Selected = true;
}现在的问题是当我选择DropDownList3后,再点击Button1_Click事件,就会报错,提示"不能绑定多个选项"
请各位帮我看看是什么原因?
protected void Button1_Click(object sender, EventArgs e)
{
for(int i=0;i<DropDownList3.Items.Count;i++)
{
DropDownList3.Items[i].Selected = false;
}
DropDownList3.Items[0].Selected = true;
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
//
} protected void Button1_Click(object sender, EventArgs e)
{
DropDownList3.ClearSelection(); //首先要取消原来的选择
DropDownList3.Items[0].Selected = true;
}
}