My question is regarding the tutorial at https://www.aspsnippets.com/Articles/ASPNet-MVC-CRUD-Select-Insert-Edit-Update-and-Delete-in-ASPNet-MVC-Razor.aspx
I modified some cells to display @Html.dropdownlistfor for the edit function. The drop down list are populated by the controller and when the user clicks edit, the current value of the cell should be the selected value of the dropdown.
@Html.DropDownListFor(m => m.SupervisorName, ViewData["SupervisorList"] as List<SelectListItem>, "", new { @id = "SupDropDownListID" })
This is my drop down list.
$("#SupDropDownListID").val(row.find(".SupervisorName").find("span").html());
This is how I am assigning the selected value.
var supName = document.getElementById("SupDropDownListID");
item.SupervisorName = supName.options[supName.selectedIndex].value;
This is how I was trying to assign the selected value before the ajax call.
And this is how I was trying to assign the selected value before the ajax call.
The issue I am finding is that this only works on the first row of cells in the table. The ajax call pulls whatever the value of that cell is instead of the cell the .update is closest to. I am a novice with javascript and have been fiddling with this for days and I am pretty stuck at this point. How do I bind the data from the selected dropdown list so that I can place it in my ajax call?