Last active
December 23, 2015 15:21
-
-
Save rionmonster/2f0cc575d5590ab92fdc to your computer and use it in GitHub Desktop.
Example of ViewBag Usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select asp-for="Group" asp-items="ViewBag.Options"> | |
<option>Please select an Option</option> | |
</select> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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