i have drop down list inside Partial view in asp.net MVC page. I am showing that partial view into the Modal Popup. I am binding values from data base to dropdown list
my problem is when i bind values to Dropdown List it binds twice?
can any one tell me why this happens
any help would be appreciated??
<select id="EntityType"></select>
function Test() {
$.ajax({
url: '/../MyFunction/',
type: 'POST',
dataType: 'json',
success: function (data) {
var options = $('#ddlcountry);
$.each(data, function() {
options.append($('<option/>').val(this.SHId).text(this.Name));
});
} // ajax callback
}); // ajax call
}
This is the output I am getting
value1
value2
value3
value1
value2
value3
Try clearing options using
$('#ddlcountry').empty()before adding new options.