asp.net mvc - MVC actionlink parameter never sending -
can tell me why parameters in following code null when controller action called:
<% foreach (var row in model) { %> <tr> <td><%=html.actionlink("edit", "edit", "customer", new { controller = "customer", action = "edit", id = row.customerid })%>| <%= html.actionlink("sales", "list", "sale", new { controller = "sale", action = "list", id = row.customerid }, null)%></td> <td><%= html.encode(row.customerid)%> </td> <td><%= html.encode(row.firstname)%> </td> <td><%= html.encode(row.lastname)%> </td> <td><%= html.encode(string.format("{0:g}", row.dateofbirth))%></td> <td><%= html.encode(row.address)%> </td> <td><%= html.encode(row.phone)%> </td> </tr> <% } %>
controller code:
public class salecontroller : controller { public actionresult list(int customerid) { salelistmodel salelist = saleservices.getlist(customerid); return view(salelist); } }
you sending parameter named id
, controller actions looking parameter named customerid
. these need match.
Comments
Post a Comment