[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to make DropDownListFor into a jQuery multiselect

Posted on 2016-08-17
6
Medium Priority
?
130 Views
Last Modified: 2016-08-17
Hello, I have the following dropdown which populates fine. I want to make it a multiselect using jQuery.  jQuery is being referenced on the view.

This is my dropdown:
@Html.DropDownListFor(m => m.StandardIndustries, Model.StandardIndustries, "Id", "Name")


This is how it is being rendered:

<select id="StandardIndustries" name="StandardIndustries">
<option value="1">Advertising</option>
<option value="2">Agriculture</option>
<option value="3">Banking / Finance / Investments</option>
<option value="4">Chemicals</option>
</select>
0
Comment
Question by:Scott Baldridge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 9

Expert Comment

by:James Bilous
ID: 41759778
This is a C# question, not Jquery or Javascript. You need to use ListBoxFor instead of DropDownListFor
0
 

Assisted Solution

by:Scott Baldridge
Scott Baldridge earned 0 total points
ID: 41759819
Thank you for responding. I'm still learning. I need a dropdown with check boxes to allow the user to select multiple items. I thought that adding a class of multiselect when jQuery is referenced will do the trick. Are you saying I need to create a ListBoxFor then make it a dropdown with CSS or something?
0
 
LVL 9

Accepted Solution

by:
James Bilous earned 2000 total points
ID: 41759914
Do you have to have checkboxes? The multi select accomplishes what you are trying to do without them.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Scott Baldridge
ID: 41759965
Yes, but I figured out my issue. The solution is similar to this bootstrap example: http://jsfiddle.net/ejqngpn5/

Except we don't use bootstrap and have similar resources.

When I found the article posted above, I made sure all the references were included to do multiselect and then it worked as expected.
0
 

Author Closing Comment

by:Scott Baldridge
ID: 41759976
Thank you for your assistance. I appreciate that you responded to my call for help. Your questions made me re-evaluate what I was trying to achieve. I was able to then find a similar solution, work through an example and notice what was missing in my environment.
0
 
LVL 9

Expert Comment

by:James Bilous
ID: 41760006
No problem, glad you figured it out!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question