I'm showing a small table with a list of usernames, and I want an ActionLink next to each username to Edit the user on another page.
Here's my view page:
<%@ Page Title="" Language="C#"
Inherits="System.Web.Mvc.ViewPage<IEnumerable<WebUI.Models.IndexModel>>" %>
<table>
<tr>
<th></th>
<th>Username</th>
</tr>
<% foreach (var item in Model) { %>
<tr>
<td><% Html.ActionLink("Edit", "Edit", "Employee", new { id = item.UserID }, null); %></td>
<td><%: item.Username %></td>
</tr>
<% } %>
</table>
My controller methods in EmployeeController:
public ActionResult Index()
{
List<IndexModel> model = new List<IndexModel>();
//load model with data
return View(model);
}
public ActionResult Edit(Guid id)
{
return View();
}
My model:
public class IndexModel
{
public Guid UserID { get; set; }
public string Username { get; set; }
}
The usernames display correctly, just the link doesn't show up. I'm not sure why it wouldn't throw an error instead.
What am I missing here?