Bind DropDown List using MVC Jquey Razor View
Hi,Not able to Bind values in DropDownlist in MVC.
Contoller
-----------
[HttpGet]
public async Task<ActionResult> GetAssiginee()
{
var AssigineeList = await this.handsService.GetTeamTask();
return Json(AssigineeList, JsonRequestBehavior.AllowGet);
}
Model :
--------
public class ClaimDetails
{
public int Assigineeid { get; set; }
public List<ClaimDetails> AssigineeList { get; set; }
public int ID { get; set; }
public string claimid { get; set; }
public string contactID { get; set; }
public string Creator { get; set; }
public string Description { get; set; }
public string status { get; set; }
public string StartDate { get; set; }
public string EndDate { get; set; }
public string ForensicDueDate { get; set; }
public string ForensicDueTime { get; set; }
public string PatientFirstName { get; set; }
public string PatientLastName { get; set; }
public string Client { get; set; }
public string ProviderName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string PreScreen { get; set; }
public string Priority { get; set; }
public string Edit { get; set; }
public string Comment { get; set; }
public string Assiginee
{
get
{
return string.Format("{0} {1}", this.FirstName ?? string.Empty, this.LastName ?? string.Empty).Trim();
}
set
{
}
}
public string Patient
{
get
{
return string.Format("{0} {1}", this.PatientFirstName ?? string.Empty, this.PatientLastName ?? string.Empty).Trim();
}
}
}
}
Script :
-------
<script type="text/javascript">
$(function(){
var items="";
$.getJSON("@Url.Action("GetAssiginee", "TeamTaskScreen")",function(data){
debugger;
$.each(data,function(index,item){
items += "<option value='" + item.claimid + "'>" + item.FirstName + "</option>";
});
$("#listProfessors").html(items);
});
});
</script>
DropDown in View:
----------------------
@Html.DropDownListFor(m => m.FirstName,
new SelectList(Enumerable.Empty<SelectListItem>(), "claimid", "FirstName"),
"Select Assiginee",
new { @style = "width: 180px;height:30px;", id = "listProfessors", @class = "form-control" })