In the below code i have dynamic dropdown and i want a value to be selected.But when i pass a value to be selected.No values are getting binded.Ples help me to do this.
if (type == "DropDownList") {
newdiv.innerHTML += "<select class=\"form-control\" data-error=\"Please Provide " + DisplayName + "\" name=\"" + Name + "\" id=\"" + Name + "\"/>";
$('#divComplete').append(newdiv);
Load(id, Name, FieldValue);
}
function Load(sFieldID, sControleID, FieldValue) {
alert(FieldValue); if (sFieldID == '')
return;
var dataString = JSON.stringify({
strProjectID: iProjectID
});
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Sample.aspx/test",
dataType: "json",
async: false,
data: dataString,
success: function (data) {
var locations = JSON.parse(data.d);
$('#' + sControleID).html("");
$.each(locations, function (i, item) {
alert(item);
$('#' + sControleID).append($('<option selected=\"true\" value=\"' + FieldValue + '\">', {
value: item.EnumText,
text: item.EnumText
}));
});
},
error: function (result) {
}
});
}