Ramco Ramco

Ramco Ramco

  • 418
  • 3.4k
  • 543.9k

Add Row in Table on Click of addRowBtn

Sep 4 2024 3:35 AM

Hi

  I have below code-behind code. I want to add rows on click of addrowbtn. How to get values.

StringBuilder htmlTable = new StringBuilder();
htmlTable.Append("<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>");
htmlTable.Append("<thead><tr style='background-color:green;color:white; text-align: center;'><th>Sr.</th><th>Document</th><th>File Name</th><th class='text-center nosort'>Action</th></tr></thead>");
htmlTable.Append("<tbody>");
htmlTable.Append("</tbody>");
htmlTable.Append("</table>");
PlaceHolderTable0.Controls.Add(new Literal { Text = htmlTable.ToString() });
<div class="row">
    <div class="col-md-12">
        <!-- Text inputs -->
        <div class="card">
            <div class="card-header bg-transparent header-elements-inline">
                <h5 class="card-title">Documents Info</h5>
                <div class="header-elements">
                    <div class="list-icons">
                        <a class="list-icons-item" data-action="collapse"></a>
                    </div>
                </div>
            </div>

            <div class="card-body">
                <div class="row">
                    <div class="col-lg-3 col-md-6 col-sm-12">
                        <div class="form-group">
                            <label>Document</label>&nbsp;<span style="color: red">*</span>
                            <asp:DropDownList ID="ddlDocument" class="form-control" runat="server" required="true">
                                <%--<asp:ListItem Value="">Select Document</asp:ListItem>--%>
                                <asp:ListItem Value="0">10th Certificate</asp:ListItem>
                                <asp:ListItem Value="1">Aadhaar Card</asp:ListItem>
                            </asp:DropDownList>
                        </div>
                    </div>
                    <div class="col-lg-3 col-md-6 col-sm-12">
                        <div class="form-group">
                            <label>Document Proof</label>&nbsp;<span style="color: red">*</span>
                            <div>
                                <asp:FileUpload ID="FileUploadIdentityProof" class="form-control" AllowMultiple="false" runat="server" />
                            </div>
                        </div>
                    </div>

                    <div class="col-lg-3 col-md-6 col-sm-12">
                        <div class="form-group">
                            <label>&nbsp;</label>&nbsp;
                            <div>
                                <button type="button" id="addRowBtn" class="btn btn-primary btn-sm"  ><i class="icon-plus22 mr-1"></i>Add</button>
                            </div>
                        </div>
                    </div>
                </div>

                <asp:PlaceHolder ID="PlaceHolderTable0" runat="server"></asp:PlaceHolder>

            </div>
        </div>
    </div>
</div>

Thanks


Answers (2)