What would be the best way to dynamically add a set of rows to a table using JQuery?

Posted by user312157 on Stack Overflow See other posts from Stack Overflow or by user312157
Published on 2010-04-08T18:02:55Z Indexed on 2010/04/08 18:13 UTC
Read the original article Hit count: 275

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about asp.net-mvc