Search code examples
c#asp.netdatagridviewupdatepanel

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


When the user selects a row in my datagrid view the label outside the datagridview does not update.

Here is my datagridview Here is what my webpage looks like

As you can see in visual studio the value of the selected row is captured. However visually it does not update.

Correct value

Here is what my datagrid code looks like.

<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>

Here is what the code for the labels outside the grid looks like

      <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>

Solution

  • I change UpdateMode="Conditional" to UpdateMode="Always" Thanks to the answer I found here how to update a control in another updatepanel?