Maddus Mattus said:
ZippyV said:

I have had my share of headache's with the HTML.ListBoxFor


One of the gotacha's is; don't put any ViewData[] or other stuff on your form that interferes with the name, ID's ect.


Here's how I use em, that I found works:


The SalesOpsManagers is just an IList<string>



= Html.ListBoxFor(model => model.SalesOpsManagers, (IEnumerable<SelectListItem>)ViewData["TerritorySalesOpsManagers"], new { style = "width:250px;" })%>


And the viewdata is in the form of a selectlistitem, doesnt need to be multiselectlist item


hope this helps you

As you can see from my controller action, I don't put anything in the viewdata.


I've seen people creating a list of SelectListItem using LINQ but they are all in C# and I have no idea how to translate it to VB.NET.



var friendNames = 
 (from tweet in friendTweets
 select new SelectListItem
  Text = tweet.ScreenName,
  Value = tweet.ScreenName
// Selected = True|False should also be filled in here