在aspx页面上,我有两个下拉控件:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="dsClients" DataTextField="Client_Name"
DataValueField="Client_Name" AutoPostBack="True" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged" ondatabound="DropDownList3_DataBound">
</asp:DropDownList>
<asp:DropDownList ID="ddQualIDInsert" runat="server" DataSourceID="dsQual" DataTextField="Project_Name"
DataValueField="Qual_ID">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList3" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
在代码隐藏文件中,我有代码根据第一个下拉菜单中的选定值更新并重建第二个下拉选项:
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
dsQual.Where = "Client_Name = \"" + ((DropDownList)sender).SelectedValue +"\"";
}
下拉获取已经填充了一些,但是大多数情况下会抛出错误:状态信息对于此页面无效并且可能已损坏。