Reputation: 327
Function Monitor() As ActionResult
Dim db = New QuarterDBContext()
Dim items As IEnumerable(Of SelectListItem) = db.getQuarter.[Select](Function(c) New SelectListItem() With
{ _
.Value = c.Quarter}), _
.Text = c.Quarter})_
})
ViewBag.Quarter = items
Return View()
End Function
I'm trying to return a value from a dropdown list using the code above. I a receiving an error that an identifier is expected at the ".text" part of the code. Any suggestions or help is greatly appreceiate! I'm stuck and can't figure out how to return a value...
Thank you!
Upvotes: 0
Views: 249
Reputation: 415705
You don't want the closing brace and parentheses after each item:
Function Monitor() As ActionResult
Dim db = New QuarterDBContext()
ViewBag.Quarter = db.getQuarter.[Select](Function(c) New SelectListItem() With
{ _
.Value = c.Quarter, _
.Text = c.Quarter _
})
Return View()
End Function
Upvotes: 1