I have a table that lists products as well as displays a quantity text box and an Html.ActionLink. Each quantity textbox has a unique id derived from the product id. I think this should be simple but I can't seem to figure out how to get the value in the associated textbox passed to my controller when the user clicks on the link. My code is below and any help is appreciated.
<% foreach (var item in Model) { %>
<tr>
<td>
<%= Html.Encode(item.Id) %>
</td>
<td>
<%= Html.Encode(item.Description) %>
</td>
<td>
<%= Html.Encode(String.Format("${0:F}", item.Cost)) %>
</td>
<td>
<%= Html.TextBox(String.Format("quantity{0}", item.Id), "0") %>
</td>
<td>
<%= Html.ActionLink("Add", "Add", new { id = item.Id, quantity="I want the quantity here?" })%>
</td>
</tr>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…