【问题标题】:Add a hyperlink to a view in a grid向网格中的视图添加超链接
【发布时间】:2020-02-07 04:44:46
【问题描述】:

我正在尝试在表中添加一列,该列具有指向另一个视图的超链接,该视图包含当前行的数据。

if (Model.Entries.Any())
{
@grid.GetHtml(tableStyle: "table table-striped table-splited", mode: WebGridPagerModes.All,
columns: grid.Columns(
        grid.Column("Request", "Request"),
        grid.Column("Response", "Response"),
        grid.Column("CustomerID", "Customer ID")));
}

我的问题是如何将带有超链接的列添加到我的其他视图?

【问题讨论】:

    标签: .net model-view-controller view controller


    【解决方案1】:
              if (Model.Entries.Any())
           {
              @grid.GetHtml(tableStyle: "table table-striped table-splited", mode: 
              WebGridPagerModes.All,
              columns: grid.Columns(
              grid.Column("Request", "Request"),
              grid.Column("Response", "Response"),
              grid.Column("CustomerID", "Customer ID")
              .RenderValueAs(o => Html.ActionLink(o.CustomerID, "TargetingNextView", new 
              { ID = o.CustomerID}));
           }
    

    \你的控制器

          public ActionResult TargetingNextView(int id)
          {
          return View();
          }                                                       
    

    【讨论】:

    • 我忘了补充,它是一个webgridcolumn,属性rendervalueas没有为它定义
    猜你喜欢
    • 1970-01-01
    • 2011-08-31
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多