I have follwoing code
@Html.DropDownList("optionsforuser", new SelectList(new[] { "Option1", "Option2", "Option3" }), "Select")
Is there anyway to initialize a value of 100 for Option1, 200 for Option2, 250 for Option3 etc within SelectList?
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 using this Extension:
and pass it a
Dictionary<string, int>with the dataValueField and dataTextField populated with your values and textSelectExtensions.DropDownList Method (HtmlHelper, String, IEnumerable(Of SelectListItem))
SelectList Constructor (IEnumerable, String, String)