datagridview 外部的标签未在 datagrid 行选定索引上更新 ASP.NET

Labe outside datagridview not updating on datagrid row selected index ASP.NET

当用户在我的数据网格视图中选择一行时,数据网格视图外部的标签不会更新。

这是我的数据网格视图

如您在 visual studio 中所见,已捕获所选行的值。但是在视觉上它不会更新。

这是我的数据网格代码的样子。

<asp:UpdatePanel ID="uplPanel"  runat="server" >
            <ContentTemplate>
           <asp:GridView ID="gvInventario" runat="server" AutoGenerateColumns="false"  AllowSorting="true" ShowFooter="false" DataKeyNames="componente_id, ubicacion_id, proveedor_id"  PageSize="20"
                ShowHeaderWhenEmpty="true" AllowPaging="True" OnPageIndexChanging="gridView_PageIndexChanging" OnSelectedIndexChanged="OnSelectedIndexChanged" OnRowDataBound="OnRowDataBound"
                 CellPadding="3"  AllowColumResize="True" onsorting="grdDetails_Sorting" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt">    
                <Columns>

网格外标签的代码如下所示

      <div id="ChangeQuantitySection"  class="menusection">
          <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
          <asp:Label ID="Label7" runat="server" Text="Cambiar la cantidad" CssClass="second-menu-title"></asp:Label>  
          <br/>
            <b><asp:Label ID="Label3" runat="server" Text="Proveedor:  "></asp:Label></b>
            <asp:Label ID="lblProveedor" runat="server" Text=""></asp:Label>
            <br/>
            <b><asp:Label ID="Label2" runat="server" Text="Tipo:  "></asp:Label></b>
            <asp:Label ID="lblType" runat="server" Text=""></asp:Label>
            <br/>
            <b><asp:Label ID="lblQtRequired" runat="server" Text="Cantidad requerida:  "></asp:Label></b>
            <asp:TextBox width="50px" ID="txtQtRequired" runat="server" TextMode="Number" min="0" step="1" Value="0"></asp:TextBox> 
          <br/>
        <asp:Button class="btn btn-primary"  ID="Button1" runat="server" Text="Validar" OnClick="Confirm_purchase_order_Click"  />

        </ContentTemplate>
            </asp:UpdatePanel>
              </div>

检查您使用的标签 ID 是否正确。因为在您的示例中,标签 ID 不一致。在您的活动中更新正确的标签。

我将 UpdateMode="Conditional" 更改为 UpdateMode="Always" 感谢我在这里找到的答案 how to update a control in another updatepanel?