My goal is to dynamically add new rows to a table by following the advice given in this answer on Stack Overflow: Add table row in jQuery
I have successfully implemented it for one of my table requirements as seen below:
function onAddItem() {
$('#myDynamicTable tr:last').after('<tr><td style="width: 78%;" class="itemName"><input type="text" style="width: 97%;" /></td><td style="width: 20%;" class="itemQty"><input type="text" style="width: 87%;" /></td></tr>');
$("#myDynamicTable").show();
}
Now, I'm attempting to apply the same concept to the following <tr>..</tr>
structure but encountering issues.
<tr class="tdBorder">
<td class="tdBorder">
@Html.TextBox("Id", null, new { @width = 60 })
</td>
<td>
@Html.TextBox("Name", null, new { @width = 150 })
</td>
<td>
@Html.DropDownList("ddlCountries", new SelectList(ViewBag.CountryList as System.Collections.IEnumerable, "Value", "Text"), new { @width = 60 })
</td>
<td>
@Html.TextBox("Event", null, new { @width = 60 })
</td>
<td>
@Html.DropDownList("ddlRegions", new SelectList(ViewBag.RegionList as System.Collections.IEnumerable, "Value", "Text"), new { @width = "auto" })
</td>
<td>
@Html.TextBox("Remarks", null, new { @width = 700 })
</td>
</tr>
I attempted the line below, however, it caused issues with jQuery:
$('#myDynamicTable tr:last').after('<tr class="tdBorder"><td class="tdBorder">@Html.TextBox("Id", null, new { @width = 60 })</td><td>@Html.TextBox("Name", null, new { @width = 150 })</td><td>@Html.DropDownList("ddlCountries", new SelectList(ViewBag.CountryList as System.Collections.IEnumerable, "Value", "Text"), new { @width = 60 })</td><td>@Html.TextBox("Event", null, new { @width = 60 })</td><td>@Html.DropDownList("ddlRegions"...