Skip to content

Instantly share code, notes, and snippets.

@rionmonster
Last active December 23, 2015 15:21
Show Gist options
  • Save rionmonster/2f0cc575d5590ab92fdc to your computer and use it in GitHub Desktop.
Save rionmonster/2f0cc575d5590ab92fdc to your computer and use it in GitHub Desktop.
Example of ViewBag Usage
<select asp-for="Group" asp-items="ViewBag.Options">
<option>Please select an Option</option>
</select>
public async Task<IActionResult> CreateGroup()
{
// Create a select list with the "B" option selected
ViewBag.Options = new SelectList(new string[]{ "A", "B", "C" }, "B");
return View();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment