What would be the best way to dynamically add a set of rows to a table using JQuery?
- by user312157
I have a following table using MVC that shows number of items the user has.
<table border = "1" id="tblItems">
<%
var itemnum = 1;
foreach (var item in Model.Items)
{%>
<tr>
<td colspan="2" bgcolor="Silver"><strong>Item#<%=itemnum%></strong></td>
<td><%=Html.ActionLink("Delete", "DeleteItem", "Item", new { id = item.ID })%></td>
</tr>
<tr>
<td><strong>Name:</strong></td>
<td><%=Html.TextBox("ItemName_" + itemnum, item.Name)%></td>
</tr>
<tr>
<td><strong>Description:</strong></td>
<td><%=Html.TextBox("ItemDescription_" + itemnum, item.Description)%></td>
</tr>
<%itemnum++;
} %>
</table>
I will have a button that will Add New Item that will dynamically add identical structure.
Any ideas on what is the best way to do this using JQuery?
Thanks for all the suggestions!