---
title: "How to a dynamic row in a table using Razor view in MVC4?"  
description: "How to a dynamic row in a table using Razor view in MVC4?"  
author: "Samuel Fernandes"  
published: 2013-10-05  
updated: 2013-10-05  
canonical: https://www.mindstick.com/forum/1588/how-to-a-dynamic-row-in-a-table-using-razor-view-in-mvc4  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 4 minutes  

---

# How to a dynamic row in a table using Razor view in MVC4?

I have a [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) in the [razor view](https://www.mindstick.com/forum/155820/how-to-generate-textbox-control-using-htmlhelper-in-razor-view) and this table contain some [Html](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript) [controls](https://www.mindstick.com/articles/66/how-to-create-controls-at-run-time-in-csharp-dot-net) like below:-

```
 <table style="text-align: center; width: 680px; background-color: White;" rules="all" id="tableId">
                <tr>
                    <td style="width: 20px;"></td>
                    <td>
                        <label>
                            Campaign Name</label>
                    </td>
                    <td>
                        <label>
                            Valid Date From</label>
                    </td>
                    <td>
                        <label>
                            Valid Date To</label>
                    </td>
                    <td>
                        <label>
                            Is Active</label>
                    </td>
                    <td>
                        <label>
                            ContractPDF</label>
                    </td>
                    <td>
                        <label>
                            Browse Contract</label>
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.HiddenFor(m => m.Customer_ID)
                    </td>
                    <td class="trBorder">
                        @Html.TextBoxFor(m => m.Customer_Name)
                    </td>
                    <td class="trBorder">
                        @Html.TextBoxFor(m => m.ValidFrom, new { @class = "datepicker" })
                    </td>
                    <td>
                        @Html.TextBoxFor(m => m.ValidTo, new { @class = "datepicker" })
                    </td>
                    <td>
                        @Html.CheckBox("gridChkCampaignIsActive", m => m.IsActive)
                    </td>
                    <td>
                        @Html.TextBoxFor(m => m.ContractDocumentPath)
                    </td>
                    <td>
                        @Html.ActionLink("Browse", "FileUpload")
                    </td>
                </tr>
            </table>
```

Add [Customer](https://www.mindstick.com/articles/325839/how-to-improve-your-business-level-of-customer-service) [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net)

```
<input type="button" value="Add
Customer" name="btnAddCustomer" id="btnAddCustomer"
style="margin-left: 20px;"/>
```

\
My [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is that I want this table like a grid [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) and when I [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) on "Add Customer" button, a blank row will be added in the grid control.

please Help me!

Any Help Will be Appreciated

## Replies

### Reply by Dag Hammarskjold

First of all , you must add jquery library to your code :

```
$("#btnAddCustomer").click(function(){
    $("#tableId tr:last").after("<tr>...</tr><tr>...</tr>");
    });
```

\

Or you can use this:

```
$("#btnAddCustomer").click(function(){$('#tableId').append('<tr><td>my data</td><td>more data</td></tr>');}); 
```


---

Original Source: https://www.mindstick.com/forum/1588/how-to-a-dynamic-row-in-a-table-using-razor-view-in-mvc4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
