troubleshooting Question

Html.DropDownList DisplayMemberPath SelectedItem

Avatar of tech1guy
tech1guyFlag for United States of America asked on
C#ASP.NETWeb Frameworks
3 Comments1 Solution746 ViewsLast Modified:
Hello there,

I'm using Visual Studio 2008 with .NET 3.5 SP1, and MVC. In one of my View, I've a DropDownBox named as "Source": "Source"'s DataSource property is binded to "Sources". Here: Sources is DTO which contains SourceId, Name, UpdatedDate, SourceType.

<%= Html.DropDownList("Source",new SelectList((IEnumerable) Model.Sources,"","Name",""))%>

I'm using DisplayMemberPath property to show ONLY "Name" (sourceName) in the dropdownBox.

My problem is HOW to get the selectedValue in the Controller?

I've tried: Source.SelectedItem, So0urce.SelectedValue, SelectedIndex.....but nothing gives us the selected value. Any help will be appreciated!!


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros