0

我在我的下拉列表中使用脚本管理器+更新面板,所以当用户选择了某些东西外,页面不会刷新(这是我的目标)。OnSelectedIndexChanged没有页面刷新事件的下拉列表

下面是HTML代码:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
<asp:ListView ID="listProducts" runat="server" DataKeyNames="ProductID" OnItemDataBound="listProducts_ItemDataBound" OnItemCommand="listProducts_ItemCommand"> 
      <ItemTemplate> 
       <div class="productoverlay"> 
        <div class="col-lg-4 proizvod"> 
         <div class="product"> 
          <div class="glow"></div> 
          <img src='<%# "../productimg/" + Eval("FileName")%>' alt='<%# Eval("ProductName") %>'/> 
         </div> 
        </div> 
        <div class="col-lg-1 price"> 
         <asp:Label ID="lblPrice" runat="server" Text=""></asp:Label> 
        </div> 
        <div class="col-lg-7 pushtop"> 
          <h1><%# Eval("ProductName") %></h1> 

         <p>Description: </p> 
         <p><%# Eval("ProductDescription") %></p> 
         <p>Quantity: </p><asp:TextBox ID="txtPackageQuantity" TextMode="Number" runat="server"></asp:TextBox>       
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
         <Triggers> 
          <asp:AsyncPostBackTrigger controlid="DropDownList1" eventname="SelectedIndexChanged" /> 
         </Triggers> 
         <ContentTemplate> 
          <asp:DropDownList ID="DropDownList1" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" runat="server"></asp:DropDownList> 
         </ContentTemplate> 
        </asp:UpdatePanel> 
         <asp:Button ID="Button1" runat="server" Text="Add to cart" CommandName="AddToCart" CommandArgument='<%# Eval("ProductID")%>'/> 
         </div> 
       </div> 
      </ItemTemplate> 
     </asp:ListView>  

这是为OnSelectedIndexChanged事件的代码:

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
     { 
      var ddl = sender as DropDownList; 
      var val = int.Parse(ddl.SelectedValue); 
      rlsp_PrCategories_ByID_Result pr = ServiceClass.ProductCatByID(val); 
      Label lblPrice = ddl.Parent.FindControl("lblPrice") as Label; 
      if(pr!=null) 
      lblPrice.Text = "$ " + pr.Price; 
     } 

的问题是,现在,当我加入脚本管理+更新面板(异步回发触发器),现在当我从下拉列表中选择某些内容时,页面不刷新,但标签也不显示任何内容(当我从下拉菜单中选择某些内容时,它应该更改价格)。

我在这里做错了什么?有人可以帮我吗?

P.S.我刚刚检查了用户是否选择了某件事情时事件触发了,并且它启动了,但我似乎无法看到该标签的内容(它未打印在页面上)......?

+0

没关系......我想它了......我不得不把标签的更新面板还... – perkes456

+0

我不使用的UpdatePanel,但具有u尝试添加: UpdatePanel1.Update() 在selectedIndexChanged处理程序的结尾? – Legends

回答

0

告诉updatepanel进行编辑之后刷新,因为updatemode在您的标记中设置为conditional。

UpdatePanel1.Update() 
相关问题