How to Bind a Jquery Dropdownlist in MVC Razor [Resolved]

Posted by Manicse under jQuery on 11/3/2016 | Points: 10 | Views : 149 | Status : [Member] | Replies : 1
Hi,

I am not able to Bind values in DropDownlist in MVC based on Razor.

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" })


Mani.R


Responses

Posted by: Rajnilari2015 on: 11/16/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Try this example : http://www.c-sharpcorner.com/uploadfile/4b0136/working-with-dropdownlist-in-mvc-5/
In case you are stuck any where, please let us know

--
Thanks & Regards,
RNA Team

Manicse, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response