Dim gridvalue = masobj.fillauditplanDet(cond)
Dim columns As New List(Of WebGridColumn)()
columns.Add(New WebGridColumn() With {.ColumnName = "Year", .Header = "Year"}) columns.Add(New WebGridColumn() With {.ColumnName = "ID", .Header = "", .Format = Function(model) New HtmlString(Html.ActionLink("Edit", "edit", New With {.ID = item.ID}).ToString())})
ViewBag.cols = columns
return PartialView("_WebGrid", gridvalue)
答案 0 :(得分:0)
最好使用tagBuilder class:
var tb = new TagBuilder("a");
tb.MergeAttribute("href",Url.Action("Edit", "edit", New With {.ID = item.ID}).ToString());
tb.AddCssClass(cssClass);
tb.ToString(TagRenderMode.SelfClosing);
columns.Add(New WebGridColumn() With {.ColumnName = "Year", .Header = "Year"}) columns.Add(New WebGridColumn() With {.ColumnName = "ID", .Header = "", .Format = Function(model) tb.ToString(TagRenderMode)})