views:

559

answers:

1

I am trying to populate a dropdownlist of office locations(text) and addresses (value) When viewing my page source in my browser after displaying the page I can see that the select (dropdownlist) option values are all "". Here is my code. I am using a LinqToSql data context call to get my data for the SelectList. In the debugger I can see that the list returned from my call does in fact have the addresses and office locations I need. My model datacontext code:

public partial class uls_dbDataContext
{
    public List<office_location> GetOfficeLocations()
    {
        return office_locations.ToList();
    }
}

My controller code:

    public ActionResult Directions()
    {
        uls_dbDataContext ulsdb_dc = new uls_dbDataContext();

        ViewData["OfficeLocations"] = new SelectList(ulsdb_dc.GetOfficeLocations(),"location_address", "location_name");

        ViewData["Title"] = "Directions";

        return View();
    }

My view code: <%= Html.DropDownList("locations", (SelectList)ViewData["OfficeLocations"])%>

A: 

I had to upgrade to MVC RC2 from preview 4. It addressed drodownlist issues and fixed my problem.

MikeD