I am fetching the data using API and assign it to VIEW BAG but at run time it shows me an error.
Code
List DevList = await RestApi.Instance.GetAllDevAsync();
var nameT = DevList.Select(a=>a.Name).ToList();
ViewBag.datasourceDevList = nameT;And in the script.
JavaScript
var nameList = ;I want to generate the dropdown list.
JavaScript
if (nameList != '') {
var tableHtml;
$.each(JSON.parse(nameList), function (index, value) {
//tableHtml += "" + value.Name + "";
console.log(value);
});
/*$("#selectTrainer").html(tableHtml);*/
$("#selectTrainer").append(tableHtml);
}
Dinesh DRank #5,346 · 302 reputationPosted Aug 27, 2021, 1:58 AM EDT