How do I retrieve row ID from an MVCContrib HTML Grid?
I currently have a product view page that contains an MVCContrib HTML Grid with a select link at the beginning of each row. If the select link is clicked, it takes 开发者_开发技巧me to a different page.
My question is whether it is possible to retrieve the productID from the row that is selected and pass that to the next page.
Maybe this is posible to do with a session variable but im not sure.
Any help would be greatly appreciated.
Thanks in advance.
Here is my view code:
<% Html.Grid((List<System2__MVC2.Controllers.ProductController.ProductsSet>)ViewData["Products"]).Columns(column =>
{
column.For(c => Html.ActionLink("Select", "Products", "Product")).DoNotEncode();
column.For(c => c.ProductID);
column.For(c => c.Name);
column.For(c => c.Description);
column.For(c => c.Price);
}).Render();
%>
Maybe I'm misunderstanding your question, but couldn't you just pass the ProductID as a route value to the ActionLink method? Something along the lines of:
Html.ActionLink("Select", "Products", "Product", new { ID = c.ProductID }, null)
精彩评论