I'm having a problem with an ASP.NET MVC application that I'm developing. I'm still fairly new at web development and in particular MVC, so please forgive me is this is a really stupid newbie mistake ;-)
I have a view that displays a list of products. Each product has a 'details' link that I want to link to a details view for that product. So, here's the relevant markup from the view:
<% foreach (var item in Model) { %>
<tr>
<td>
<%= Html.ActionLink("Edit", "Edit", new { id=item.StockCode.ToString() }) %>
<%= Html.ActionLink("Details", "Details", new { id=item.StockCode.ToString() })%>
</td>
<td>
<%= Html.Encode(item.StockCode) %>
</td>
<td>
<%= Html.Encode(item.Description) %>
</td>
</tr>
<% } %>
So far so good. When I hover the mouse over the details link in the web browser, the link shows up as:
R8517 is the stock code for the item. So, that's what I expect to see in my Action Method. Here's the Action Method:
//
// GET: /RawMaterial/Details/5
public ActionResult Details(string stockCode)
{
return View(repository.GetByStockCode(stockCode));
}
But... when the Action Method executes, the parameter (stockCode) is null.
Any thoughts?