In my scenrio dropdown is loading properly with list of records.
When click edit- dropdown want to loaded and set the pre selected or database value want to come first
for ex if list as "--select--"
one
Two
Three
And if choose "Two" and saved in db
next time dropdown should be loaded as "Two" as default or selected index
For me every time dropdown loaded as
"--select--"
one
Two
Three
this is the code
////
$.each(response.CodeValueList, function (data, value) {
if (value.CodeValueId == response.Currentid)// checking pre selected value with list of value
{
$("#ddlid").append($('', { value: value.CodeValueId, selected: 'selected', html: value.Value }));
}
else {
$("#ddlid").append($('', { value: value.CodeValueId, html: value.Value }));
}
})
@Html.DropDownList("ddlid", Enumerable.Empty(), "---Select---", new { @style = "width: 100%;", @id = "ddlid" })
Note while debugging condition satisfying going to respective section but at last iam getting --select-- only as first item
Please help on this
Jignesh KumarPosted Jun 19, 2020, 10:29 PM
Laxmidhar SahooPosted Jun 19, 2020, 8:20 AM