An HTML select's selected value is submitted not the text. If you want the text submitted then set the Id to the text value too. I assume you'll need to update the associated model (action input parameter) from an int to a string.
private List<ItemTypes> GetITs()
{
var itemtypes = new List<ItemTypes>();
itemtypes.Add(new ItemTypes() {Id = "Buy Item", Title = "Buy Item" });
itemtypes.Add(new ItemTypes() {Id = "Raw Components", Title = "Raw Components" });
return itemtypes;
}
public class ItemTypes
{
public string Id { get; set; }
public string Title { get; set; }
}
Also, you could populate a List<SelectListItem> rather than building a custom ItemTypes type.
https://learn.microsoft.com/en-us/dotnet/api/system.web.mvc.selectlistitem?view=aspnet-mvc-5.2
Example
public class ViewModel
{
public string SelectedOption { get; set; }
}
public class BasicFormsController : Controller
{
// GET: BasicForms
[HttpGet]
public ActionResult Index()
{
ViewBag.Options = PopulateOptions();
return View();
}
[HttpPost]
public ActionResult Index(ViewModel model)
{
ViewBag.Options = PopulateOptions();
return View(model);
}
private List<SelectListItem> PopulateOptions()
{
List<SelectListItem> options = new List<SelectListItem>()
{
new SelectListItem()
{
Text = "Buy Item",
Value = "Buy Item"
},
new SelectListItem()
{
Text = "Raw Components",
Value = "Raw Components"
}
};
return options;
}
}
View
@model MvcBasic.Controllers.ViewModel
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Index</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>ViewModel</h4>
<hr />
<div class="form-group">
<div class="col-md-10">
<div class="checkbox">
@Html.DropDownListFor(model => model.SelectedOption, (List<SelectListItem>)ViewBag.Options)
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Submit" class="btn btn-default" />
</div>
</div>
</div>
}