I'm working my way through the NerdDinner tutorial trying to learn ASP.NET MVC and because I'm more a VB.NET type of person I'm converting the code to VB.NET while reading. But now I'm stuck on creating a populated dropdownlist.
The controller fills the ViewData:
<%= Html.DropDownList("Country", ViewData["Countries"] as SelectList) %>
It's this View that I cannot get to work in VB.NET, I cannot find the conversion for ViewData["xxx"] as SelectList. Hope someone can give me tip.
U r right. ViewData is of type ViewDataDictionary which is a dictionary and as u have a VB.net background, u definitely know how to handle the dictionaries. (ViewData("item") instead of ViewData["item"])
Share if u know something and ask if u don't. Mark as Answer if it is helpful.
Oh, I feel ashamed it was this easy. Thanks. It must have been a lack of sleep
@ricka6: There is a NerdDinnerVB on CodePlex but it contains only the first steps of the application tutorial. I will finish my conversion as soon as possible and hopefully put it online.
StievieD
Member
122 Points
33 Posts
DropDownList in VB.NET (NerdDinner tutorial)
Aug 10, 2009 12:21 PM|LINK
I'm working my way through the NerdDinner tutorial trying to learn ASP.NET MVC and because I'm more a VB.NET type of person I'm converting the code to VB.NET while reading. But now I'm stuck on creating a populated dropdownlist.
The controller fills the ViewData:
<%= Html.DropDownList("Country", ViewData["Countries"] as SelectList) %>It's this View that I cannot get to work in VB.NET, I cannot find the conversion for ViewData["xxx"] as SelectList. Hope someone can give me tip.Augi
Contributor
6730 Points
1142 Posts
Re: DropDownList in VB.NET (NerdDinner tutorial)
Aug 10, 2009 12:38 PM|LINK
<%= Html.DropDownList("Country", TryCast(ViewData["Countries"], SelectList)) %>sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: DropDownList in VB.NET (NerdDinner tutorial)
Aug 10, 2009 03:38 PM|LINK
I think vb indexers are more like ViewData("Countries") not using [].
MVC vb.net
Always seeking an elegant solution.
ZafarYousafi
Contributor
2542 Points
401 Posts
Re: DropDownList in VB.NET (NerdDinner tutorial)
Aug 10, 2009 04:20 PM|LINK
U r right. ViewData is of type ViewDataDictionary which is a dictionary and as u have a VB.net background, u definitely know how to handle the dictionaries. (ViewData("item") instead of ViewData["item"])
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: DropDownList in VB.NET (NerdDinner tutorial)
Aug 10, 2009 04:47 PM|LINK
The free C#/VB conversion tools yield
Html.DropDownList("Country", TryCast(ViewData("Countries"), SelectList))
It would be nice to post a good VB version of NerdDinner on codeplex.
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: DropDownList in VB.NET (NerdDinner tutorial)
Aug 10, 2009 06:22 PM|LINK
Hi rick that would be a cool resource but my VB skill are poorly lacking [:$]
MVC vb.net NerdDinner
Always seeking an elegant solution.
StievieD
Member
122 Points
33 Posts
Re: DropDownList in VB.NET (NerdDinner tutorial)
Aug 10, 2009 06:28 PM|LINK
Oh, I feel ashamed it was this easy. Thanks. It must have been a lack of sleep
@ricka6: There is a NerdDinnerVB on CodePlex but it contains only the first steps of the application tutorial. I will finish my conversion as soon as possible and hopefully put it online.
13gowthami
Member
30 Points
32 Posts
Re: DropDownList in VB.NET (NerdDinner tutorial)
Feb 22, 2012 07:37 PM|LINK
Hello Stievie,
Is there a VB.NET version of NerdDinner, if so can you please post the link?
Thanks in Advance,
Thota.