2012-06-11 25 views
0

我有一个带有3个下拉框的ASPX页面,通过Infragistic控件。其中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) 
    { 

    } 
} 

回答

0

我会尝试寻找AutoPostBackFlags之一的SelectionChanged,另一个是的valueChanged有可能这只是事实上,因为这两个事件正在触发的原因是为什么它回发两次?