I am currently working on implementing inline CRUD operations in MVC 5. When a user clicks a specific button to add new records, it should create a dynamic table row. Below is the JavaScript code I am using:
function tblnewrow() {
var newrow = '<tr>' +
'<td><span class="edit-mode"><input type="text" class="form-control edit-mode" id="particular" placeholder="Enter Particular"/></span></td>' +
'<td><span class="edit-mode"><input type="text" class="form-control edit-mode" id="acctcode" placeholder="Enter Account Code" /></span></td>' +
'<td><span class="edit-mode"><input type="text" class="form-control edit-mode" id="ppmpcode" placeholder="Enter PPMP Code" /></span></td>' +
'<td><span class="edit-mode">@Html.DropDownList("Account Code", (SelectList)ViewBag.listValues, "---Select Account Code---", new { @class = "form-control edit-mode", id = "acctcode" })</span></td>' +
'<td align="center"><button class="btn btn-success edit-mode" id="saveParticular" type="submit">Save</button><button class="btn btn-danger cancel-add edit-mode">Cancel</button></td>'
$('#particularTbl tr:last').after(newrow);
};
I have successfully added a new row, but I'm encountering an issue when adding a dropdown list - it doesn't seem to be functioning correctly. Can anyone point out what might be wrong here? Thank you in advance!