UpdatePanel内的ASP.NET标签未在所选索引上更新

时间:2019-03-24 20:35:24

标签: asp.net updatepanel

我是ASP.NET的新手,我试图获取一个Label来更新某些信息,这些信息在我按On on selected index changes时可以获取。调用On selected index changes函数并返回就可以了(我已经调试并逐步完成了整个过程)。唯一不起作用的是在我设置要更新的标签文本的地方。

这是在更改选定索引时单击的调用的函数:

  protected void OnClosetIndexChanged(object sender, EventArgs e)
    {
        {
            UpdatePanel updatePanel1 = Row.FindControl("UpdatePanel1") as UpdatePanel;
            Label oldSourceQuantity = (Label)Row.FindControl("lblQuantity");
            oldSourceQuantity.Text = "0";//Trying to force a value
            updatePanel1.Update();
        }

    }

我知道它会进入if并尝试设置文本,但是客户端没有任何反应。

这是我拥有的UpdatePanel:

 <asp:TemplateField>
                    <ItemTemplate>
                        <tr>
                           <td colspan="100%" style="background:#F5F5F5" >
                             <div id="div<%# Eval("componente_id") %>"  style="overflow:auto; display:none; position: relative; left: 15px; overflow: auto">
                        <div class="ExpandTableHeader">
                         Cambiar la cantidad
                        </div>
                        <div class="body">
                            <label for="validationOfTypeID">Armario:</label>
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server"  UpdateMode="Always"  ChildrenAsTriggers="true">
                             <ContentTemplate>
                            <asp:DropDownList ID="drCloset" AppendDataBoundItems="True" runat="server" Width="20%" Height="30px" AutoPostBack="true" OnSelectedIndexChanged = "OnClosetIndexChanged"></asp:DropDownList>
                           <br/>
                                  <label for="validationOfTypeID" visible="false" >cajon</label> <br/> 
                              <asp:DropDownList ID = "drDrawer"  AutoPostBack="true" runat="server" Width="20%" Height="30px" >
                             </asp:DropDownList>


                           <asp:Label ID="lblQuantity" runat="server" Text=""></asp:Label>
                            </ContentTemplate>
                           <Triggers>
                              <asp:AsyncPostbackTrigger ControlID="drCloset" EventName="SelectedIndexChanged" />
                           </Triggers>
                                 </asp:UpdatePanel>
                             <label for="validationOfTypeID"></label>
                               <asp:DropDownList Height="30px" ID="drOperation" runat="server" >
                                   <asp:ListItem>+</asp:ListItem>
                                   <asp:ListItem>-</asp:ListItem>
                            </asp:DropDownList> 

                            <asp:TextBox width="50px" ID="txtChangeQuantity" runat="server" TextMode="Number" min="0" step="1" Value="0"  ></asp:TextBox>
                              <asp:Label ID="lblTotal" runat="server" Text=""></asp:Label>

                              <br/>
                            </br>
                            <asp:Button class="btn btn-primary" ID="btnConfirmPurchases" runat="server" Text="Validar" AutoPostback="true" width="20%"  /> 


                        </div>
                          <asp:DetailsView id="DetailsView1" DataKeyNames="componente_id" Runat="server" Width="300px" Font-Names="Calibri"/>                              
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:TemplateField>

0 个答案:

没有答案