如何从MVCContrib HTML Grid检索行ID?

时间:2021-02-04 15:13:43

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.

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

My question is whether it is possible to retrieve the productID from the row that is selected and pass that to the next page.

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

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

1 个解决方案

#1


1  

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:

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

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

#1


1  

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:

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

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