A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
Hi @EB ,
I tested the code you provided, and I found two places that need to be modified:
- The last "case" lacks a break.
- case "4": category.Add(new SelectListItem { Text = "---Select---", Value = null }); category.Add(new SelectListItem { Text = "Address", Value = "Address" }); category.Add(new SelectListItem { Text = "Closing", Value = "Closing" }); break; - You should first empty the html of $("#Catagory") and then fill it.
$("#Catagory").empty();-
$.each(category, function (i, category) {
$("#Catagory").append('<option value="' + category.Value + '">' +
category.Text + '</option>');
});
Code - Controller
- View
Result
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
YihuiSun