TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
prabhu p
NA
181
114.4k
How to load a dropdown using jquery in mvc 5 Ajax call
Jun 19 2020 7:00 AM
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($('<option/>', { value: value.CodeValueId, selected: 'selected', html: value.Value }));
}
else {
$("#ddlid").append($('<option/>', { value: value.CodeValueId, html: value.Value }));
}
})
@Html.DropDownList("ddlid", Enumerable.Empty<SelectListItem>(), "---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
Reply
Answers (
2
)
how to create stored procedure phpmyadmin
Customizable keybinds C#