如何从MVCContrib HTML Grid检索行ID?

时间:2010-03-23 19:23:05

标签: asp.net-mvc row session-variables mvccontrib

我目前有一个产品视图页面,其中包含一个MVCContrib HTML网格,每行开头都有一个选择链接。如果单击选择链接,则会转到另一页。

我的问题是,是否可以从所选行中检索productID并将其传递到下一页。

也许这对于会话变量是可行的,但我不确定。

非常感谢任何帮助。

提前致谢。

这是我的观看代码:

<% 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();             
%>

1 个答案:

答案 0 :(得分:1)

也许我误解了你的问题,但你不能只将ProductID作为路径值传递给ActionLink方法吗?有点像:

Html.ActionLink("Select", "Products", "Product", new { ID = c.ProductID }, null)