我通过 Infragistic 控件有一个带有 3 个下拉框的 ASPX 页面。其中 1 个位于 UpdatePanel 内部,而 UpdatePanel 外部的两个假设通过 AsynPostBack 事件控制第三个中显示的内容。UpdatePanel 外部的两个下拉框在后面的代码中调用相同的函数,但取决于我传递给它的对象,它会在第三个下拉框中显示一些内容。问题是,无论我选择哪个下拉框,该函数似乎都被触发了两次,并且每个调用都将其控制权传递给该函数,而第二个调用始终显示,即使我单击第一个调用也是如此。我该如何阻止它?我期望该功能仅触发一次,具体取决于我选择的控件。我还尝试让每个下拉框都指向它自己的功能,但它们都被触发了......
<td style="width:3px;"><asp:HiddenField ID="pnb_recno" runat="server" /></td>
<td style="width:100px;">Line Of Business:</td>
<td colspan="2" width="150px"><!--OnSelectionChanged="pnb_product_list"-->
<ig:WebDropDown ID="pnb_ddRgn" runat="server" Width="175px" DropDownContainerHeight="100px"
EnableDropDownAsChild="false" TextField="Name" DropDownContainerWidth="175px" Font-Size="11px"
StyleSetName="Windows7" OnSelectionChanged="pnb_product_list" AutoPostBack="true" ClientEvents-SelectionChanged="pnb_chgLOB" >
<Items>
<ig:DropDownItem Text="" Value="" />
<ig:DropDownItem Text="Global Client Access" Value="Global Client Access" />
<ig:DropDownItem Text="Solution Center" Value="Solution Center" />
<ig:DropDownItem Text="Both" Value="Both" />
</Items>
</ig:WebDropDown>
</td>
<td style="width:3px;"></td>
<td style="width:100px;">Problem Type:</td>
<td colspan="2" width="150px">
<ig:WebDropDown ID="pnb_ddPblmTyp" runat="server" Width="175px" DropDownContainerHeight="80px" EnableDropDownAsChild="false" TextField="Name" DropDownContainerWidth="175px" Font-Size="11px" StyleSetName="Windows7" AutoPostBack="true" OnSelectionChanged="pnb_product_list">
<Items>
<ig:DropDownItem Text="" Value="" />
<ig:DropDownItem Text="Infrustructure" Value="Infrustructure" />
<ig:DropDownItem Text="Products" Value="Products" />
</Items>
</ig:WebDropDown>
</td>
<td colspan="2" width="150px">
<asp:UpdatePanel ID="pnb_udtPnlPrdts" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="pnb_ddRgn" EventName="SelectionChanged" />
<asp:AsyncPostBackTrigger ControlID="pnb_ddPblmTyp" EventName="SelectionChanged" />
</Triggers>
<ContentTemplate>
<ig:WebDropDown ID="pnb_ddPrdts" runat="server" Width="175px" EnableClosingDropDownOnSelect="false" TextField="ProductName" EnablePaging="false" DropDownContainerHeight="175px" EnableMultipleSelection="true" MultipleSelectionType="Checkbox" StyleSetName="Windows7" DisplayMode="DropDown">
<ClientEvents SelectionChanged="selectedIndexChanged" SelectionChanging="selectedIndexChanging" />
</ig:WebDropDown>
</ContentTemplate>
</asp:UpdatePanel>
</td>
protected void pnb_product_list(object sender, EventArgs e)
{
try
{
using (SqlConnection sqlConnection = new SqlConnection(connectionString))
{
using (SqlCommand sqlCommand = new SqlCommand("dbo.getDdProducts", sqlConnection))
{
sqlCommand.CommandTimeout = 0;
sqlCommand.CommandType = CommandType.StoredProcedure;
if (!String.IsNullOrEmpty(pnb_ddRgn.CurrentValue))
sqlCommand.Parameters.AddWithValue("@lob", pnb_ddRgn.CurrentValue);
else
sqlCommand.Parameters.AddWithValue("@alert_type", pnb_ddPblmTyp.CurrentValue);
using (DataTable dataTable = new DataTable())
{
using (SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCommand))
{
dataAdapter.Fill(dataTable);
}
pnb_ddPrdts.DataSource = dataTable;
pnb_ddPrdts.DataBind();
}
}
}
}
catch (Exception exception)
{
}
}