I have taken File > Project > New Project >Choose Template MVC >select MVC WebForm also when i am trying to code register view any Jquery It was not working.How could i solve this error.Error will show in dropdownlist.This is the error
"The ViewData item that has the key 'Country' is of type 'System.String' but must be of type 'IEnumerable<SelectListItem>'.."
==code Jquery==
$(document).ready(function () {
$("#dd_Country").change(function () {
var countryId = $(this).val();
$.getJSON("Account", "LoadStatesByCountryId", { Countryid: countryId },
function (classesData) {
var select = $("#ddState");
select.empty();
select.append($('<option/>', {
value: 0,
text: "Select a State"
}));
$.each(classesData, function (index, itemData) {
select.append($('<option/>', {
value: itemData.Value,
text: itemData.Text
}));
});
});
});
});
</script>*@
==this the code for dropdownlist==
<div class="form-group">
@Html.LabelFor(m => m.Country, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.DropDownList("Country",null,"--Select Citizenship--", new { @class = "form-control" })
@*@Html.DropDownListFor(m => m.Country, new SelectList(ViewBag.Countries as System.Collections.IEnumerable, "Id", "Name"),
"Select a Country", new { id = "dd_Country", @class = "form-control" })*@
@Html.ValidationMessageFor(model => model.Country, "", new { @class = "text-danger" })
</div>
</div>