将WebGrid数据显示为链接

时间:2013-07-05 10:59:05

标签: html jquery-ui jquery webgrid

     <div>
@{    
    var grid = new WebGrid(Model.lstTravelReadyEntities, canPage: true, rowsPerPage: 3,ajaxUpdateContainerId:"table");
    grid.Pager(WebGridPagerModes.NextPrevious);  
    @grid.GetHtml(htmlAttributes:new{id="table"}, 
    headerStyle: "Header",
    alternatingRowStyle: "alt",
    columns: grid.Columns(
     grid.Column("Var_AssoId", canSort: true, format:@<b>@Html.ActionLink(item.Var_AssoId, "Details", "Home", new { id = item.Var_AssoId }, null)</b>, style: "Number")         grid.Column("Var_AssociateName", "Var_AssociateName")
    ));
}

这是我的View它返回错误页面。如何将表数据(Var_AssoId)设置为链接?

1 个答案:

答案 0 :(得分:0)

试试这个:

grid.Column(header: "Var_AssoId", format: item => new HtmlString(
       Html.ActionLink((string)item.Var_AssoId.ToString(), "Details", new { id = item.Var_AssoId } ).ToString()))