Why is the initial value of my dropdownlist not showing? I’m using:
@Html.DropDownList("DropDownValues", new SelectList(ViewBag.sellectedSubjectsId, "Initial Value"));
What am I doing wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try to avoid using Dynamic stuff like
ViewBagandViewDatafor transferring data between action method and views. Use strongly typed view models.Assume your view is to Create a new course where user has to select one subject from a list of subjects, create a view model like this
And in your
GETaction, create an object of your view model and fill the Subjects property.Now in your view, which is strongly typed to your view model.