I have a list of names which is fetched from database, I want when user select any one of the name then its id will be saved in a variable & then on submit the form I receive this id on server. I am wondering is it possible? I am pretty new to this technology.
Here's my code
controller
public ActionResult Index()
{
MyUsers user = new MyUsers();
List<MyUsers> result = user.GetAllUser();
return View(result);
}
View
<h2>Products</h2>
@using (Html.BeginForm())
{
<ul>
@foreach (var item in Model)
{
<li>@item.Name</li>
}
</ul>
<input type="submit" value="Click Me" />
}