Im getting the values into the dropdown list from the database,
But im not been able to populate it on the multiple textboxes.
@*@Html.DropDownList("Branchcode", new SelectList(ViewBag.Branches, "Taskid", "Taskid"), "Select Branch", new { @id = "ddlBranches", @class = "SelectCtrlGHN", onchange = "return get_sbu(this)" })*@
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function get_sbu() {
var selected_val = $('#ddlBranches').find(":selected").attr('value');
$.ajax({
type: "POST",
url: "/TaskList/selectSBU",
data: "id=" + selected_val,
success: function (data) {
if (data.length > 0) {
$('#task').val(data[0].taskid);
$('#task2').val(data[0].Tskds1);
}
else {
$('#task').val('');
$('#task2').val('');
}
}
});
}
</script>
</div>
private static List<CrTaskList> Populatelist()
{
TaskListMaintenance tkl = new TaskListMaintenance();
List<CrTaskList> branches = tkl.getTaskMaintenanceListdata();
return branches;
}
public JsonResult selectSBU(string id)
{
List<CrTaskList> branches = Populatelist();
return Json(branches.Where(x => x.Taskid == id));
}
private JsonResult Json(IEnumerable<CrTaskList> enumerable, object allowGet)
{
throw new NotImplementedException();
}