|
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<div>
<ejs-multiselect id="games" dataSource="@ViewBag.data" placeholder="Favorite Sports" mode="Box">
<e-multiselect-fields value="Id" text="Game"></e-multiselect-fields>
</ejs-multiselect>
<button id="reload" type="submit">Submit Values</button>
</div>
} |
|
public IActionResult Index()
{
ViewBag.data = new GameList().GameLists();
return View();
}
[HttpPost]
public IActionResult Index(List<string> games)
{
ViewBag.data = new GameList().GameLists();
var selectedValues = games;
return View();
}
public class GameList
{
public string Id { get; set; }
public string Game { get; set; }
public List<GameList> GameLists()
{
List<GameList> game = new List<GameList>();
game.Add(new GameList { Id = "Game1", Game = "Football" });
game.Add(new GameList { Id = "Game2", Game = "Badminton" });
game.Add(new GameList { Id = "Game3", Game = "Basketball" });
game.Add(new GameList { Id = "Game4", Game = "Cricket" });
game.Add(new GameList { Id = "Game5", Game = "Football" });
game.Add(new GameList { Id = "Game6", Game = "Golf" });
game.Add(new GameList { Id = "Game7", Game = "Hockey" });
game.Add(new GameList { Id = "Game8", Game = "Rugby" });
game.Add(new GameList { Id = "Game9", Game = "Snooker" });
game.Add(new GameList { Id = "Game10", Game = "Tennis" });
return game;
}
}
|
|
[HttpPost]
public IActionResult Index(string[] games)
{
ViewBag.data = new GameList().GameLists();
var selectedValues = games;
return View();
}
|
|
@model multiviewmodel.Controllers.Games
<form asp-action="Index" asp-controller="Home" method="post">
<div>
<ejs-multiselect ejs-for="@Model.Game" name="Game" id="Game" dataSource="@Model.Data" placeholder="Favorite Sports" mode="Box">
<e-multiselect-fields value="Id" text="Game"></e-multiselect-fields>
</ejs-multiselect>
<button id="reload" type="submit">Submit Values</button>
</div>
</form> |
|
public IActionResult Index()
{
Games game = new Games();
game.Data = new GameList().GameLists();
game.Game = new string[] { "Game7" };
return View(game);
}
[HttpPost]
public IActionResult Index(Games games)
{
games.Data = new GameList().GameLists();
return View(games);
} |
|
public class Games
{
public string[] Game { get; set; }
public List<GameList> Data { get; set; }
} |