0

I want to show a textbox inside the cell of a gridview, when clicking on a button inside another cell of the same gridview and replace button for checkbox.

like this:

before click edit button:

enter image description here

and after click button like this:

enter image description here

this is the html of gridview

                                <asp:GridView runat="server" ID="GdVDocumentosFamilia" CssClass="tableCont tableContInfo genTbl tblCenter yellow" OnRowDataBound="GdVDocumentosFamilia_RowDataBound" AutoGenerateColumns="false">
                                    <Columns>
                                        <asp:BoundField DataField="Nombre" />
                                        <asp:BoundField DataField="RelacionFFdE" />                                      
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                 <asp:Label ID="lblTiene" runat="server" CssClass="labelBoldForm"></asp:Label>
                                                <asp:LinkButton runat="server" ID="lnkMod" CommandName="cmdMod" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CssClass="btn btn-secondary btn-icon btn-2">
                                                    <span class="btn-inner--icon"><i class="far fa-edit"></i></span>
                                                </asp:LinkButton>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                         <asp:BoundField DataField="PartidaNacimiento"  HeaderStyle-CssClass="ocultar" ItemStyle-CssClass="ocultar"/>
                                        <asp:BoundField DataField="CUI" />
                                    </Columns>
                                </asp:GridView>

this how a fill that:

        public void DocumentoFamilia(DataTable dt)
    {
        foreach (DataRow row in dt.Rows)
        {
             row["CUI"] = String.IsNullOrEmpty(row["CUI"].ToString()) ? "Pendiente" : row["CUI"];
        }
        GdVDocumentosFamilia.Columns[0].HeaderText = "Nombre";
        GdVDocumentosFamilia.Columns[1].HeaderText = "Relación";
        GdVDocumentosFamilia.Columns[2].HeaderText = "Partida de nacimiento/CUI";
        GdVDocumentosFamilia.Columns[4].HeaderText = "Número de CUI";
        GdVDocumentosFamilia.DataSource = dt;
        GdVDocumentosFamilia.DataBind();

        foreach (GridViewRow row in GdVDocumentosFamilia.Rows)
        {
            row.Cells[1].Text = String.IsNullOrEmpty(row.Cells[1].Text) ? "Pendiente" : row.Cells[1].Text;
            row.Cells[1].ForeColor = row.Cells[1].Text == "Pendiente" ? Color.Red : Color.Empty;
            row.Cells[4].ForeColor = row.Cells[4].Text != "Pendiente" ? Color.Empty : Color.Red;
        }
    }

and finally this is the rowdatabound.

 protected void GdVDocumentosFamilia_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string tienecui = e.Row.Cells[3].Text;
            if (tienecui != "NO")
            {
                LinkButton lnkMod = e.Row.FindControl("lnkMod") as LinkButton;
                lnkMod.Visible = false;
                Label lblTiene = e.Row.FindControl("lblTiene") as Label;
                lblTiene.Text = "SI";
            }

        }

    }

0 Answers0