I'm looking to pass the value selected in the drop box when I click submit. Instead, it's passing a null value and I'm confused as to why. Any help is appreciated!!
Controller:
Namespace DHR
Public Class WorkSampleController
Inherits System.Web.Mvc.Controller
Private dbQ As QuarterDBContext = New QuarterDBContext
Private db As WorkSampleDBContext = New WorkSampleDBContext
Function Index() As ViewResult
Dim quarterList As New List(Of String)()
Dim QuarterQry = From d In dbQ.getQuarter
Order By d.ID
Select d.Quarter
quarterList.AddRange(QuarterQry.Distinct())
ViewBag.Quarter = New SelectList(quarterList)
Return View(db.WorkSample.ToList())
End Function
<HttpPost()>
Function Index(ByVal quarterID As Integer) As ActionResult
Dim quarter As String = "null"
If quarterID = 1 Then
quarter = "Dec, Jan, Feb"
End If
ViewBag.test = quarter
Return View()
End Function
View:
@ModelType IEnumerable(Of DHR.WorkSample)
@Code
ViewData("Title") = "Monitor"
Using (Html.BeginForm())
@<p> Type: @Html.DropDownList("SampleType")
Quarter: @Html.DropDownList("Quarter")
<input type="submit" value="Filter" /></p>
End Using
End Code