how to bind data in dropdownlist in asp.net MVC c# from datatable
public ActionResult bind_InstituteMaster()
{
var dt = dal.GetList("table ORDER BY Name ASC", "*", "");
return Json(Lookup.DataTableToJSONWithJSONNet(dt), JsonRequestBehavior.AllowGet);
}
public static string DataTableToJSONWithJSONNet(DataTable table)
{
string JSONString = string.Empty;
JSONString = JsonConvert.SerializeObject(table);
return JSONString;
}
$.get("/user/bind_InstituteMaster", {}, function (data) {
$.each(JSON.parse(data), function (i, v) {
$('#ddl_name').append('<option value="' + v.Inst_Name + '">' + v.Inst_Name + '</option>');
})
});
2020-01-20