【问题标题】:How do I retrieve row ID from an MVCContrib HTML Grid?如何从 MVCContrib HTML 网格中检索行 ID?
【发布时间】:2010-03-23 19:23:04
【问题描述】:

我目前有一个产品视图页面,其中包含一个 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();             
%>

【问题讨论】:

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


    【解决方案1】:

    也许我误解了您的问题,但您不能将 ProductID 作为路由值传递给 ActionLink 方法吗?大致如下:

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

    【讨论】:

    • 啊...非常感谢,我是 ASP MVC 的新手,但没有意识到您可以做到这一点。再次感谢。
    猜你喜欢
    • 2011-02-23
    • 1970-01-01
    • 1970-01-01
    • 2011-07-22
    • 1970-01-01
    • 1970-01-01
    • 2010-10-24
    • 1970-01-01
    • 2011-02-11
    相关资源
    最近更新 更多