I am trying to load data into my page through a parameter, but the parameter is not being passed. Here is the part of my view that is passing a value:
@using (Html.BeginForm()){
<text>Team </text>@Html.DropDownList("Tm", new SelectList(ViewBag.Teams))
<input type="submit" value="Search" />
}`
The "Tm" should be the value that is getting passed once a value is selected and the submit button is clicked. It should by passed to the following function in the controller
public ActionResult Index(int? Tm)
{
if (Tm == 0)
{
Tm = 1;
}
string connectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\Webs\MvcFFL\MvcFFL\App_Data\aspnet-MvcFFL-20140517174741.mdf;Integrated Security=True";
}
unfortunately the value of Tm comes in as null. If I removed the ? from int in the controller then it throws an error. So what can i do to make sure the value is passed so my controller can send the data back to the page correctly?
**UPDATE** I am posting the thing that is returning to the page:
var mdl = from r in db.Teamplayers
where r.teamid == f
select r;
return View(mdl);
f is an integer in this case
UPDATE #2 Here is my ViewBag.Teams, that the selectlist gets the info from:
ViewBag.Teams = (from r in db.FTeams
where r.UserID == curID
select r.FTeam).Distinct();