I'm just trying to put a SelectList into the ViewBag but I can't access it right after.
Here's my code:
// GET: Content/CreateSerie
public ActionResult CreateSerie()
{
ViewBag.originalLang = new SelectList(db.Lang, "originalLang", "originalLang");
return View();
}
If I use the debugger to step right after the ViewBag.originalLang
assignation and use the expression evaluator, I get
However, if I go deeper into the ViewBag I can see
This is really weird and I don't get why I can't access it normally. Of course, I can't access it from the view either.
EDIT: Here's my View as erdi yılmaz requested:
@model e08projh17.Models.Content
@{
ViewBag.Title = "Créer une série";
@Styles.Render("~/Content/css")
@Styles.Render("~/Content/themes/base/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jqueryui")
}
<h2>CreateSerie</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Content</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<!-- Lots of stuff ... -->
<div class="form-group">
@Html.LabelFor(model => model.originalLang, "Langue originale", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.originalLang, (SelectList)ViewBag.originalLang, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.originalLang, "", new { @class = "text-danger" })
</div>
</div>
<!-- Lots of stuff ... -->
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>@Html.ActionLink("Back to List", "Index")</div>
@section Scripts { @Scripts.Render("~/bundles/jqueryval") }