我想在嵌套列上调用父源的PkId为nestgrd.Column(“Qty”,格式:( item)=> Html.ActionLink((string)item.Product.ToString(),“FreeGiftQuantityViews”,新{id = item.PkId}但我无法打电话。如何将新{id = item.PkId}称为新{id = pkglist.item.PkId}
<div id="lgrid" class="tablesorter">
@{
var grid = new WebGrid(Model.pkglist, rowsPerPage: 10, canSort: false, canPage: false, ajaxUpdateContainerId: "lgrid");
}
@grid.GetHtml(
tableStyle: "lgrid",
headerStyle: "head",
alternatingRowStyle: "alt",
columns: grid.Columns(
grid.Column("S.N.", format: @<text>@{count++;}@count</text>, style: "sn"),
grid.Column("PkId", format: @<text>@item.PkId</text>),
grid.Column("Package Name", format: @<text>@item.PackageName</text>),
grid.Column("Product", format: @<text>@item.Product</text>),
grid.Column("Access", format: @<text>@item.Access</text>),
grid.Column("Rate", format: @<text>@item.Rate</text>),
grid.Column("Remarks", format: @<text>@item.Remarks</text>),
grid.Column("Edit", format: (item) => Html.ActionLink("Edit", "EditPackage", new { id = item.PkId }, new { @class = "openDialog", data_dialog_id = "emailDialog", data_dialog_title = "Edit" })),
grid.Column("Delete", format: (item) => Html.ActionLink("Delete", "DeletePackage", new { id = item.PkId }, new { @class = "openDialog", data_dialog_id = "emailDialog", data_dialog_title = "Delete" })),
grid.Column("Free Package Lists", format: row =>
{
WebGrid nestgrd = new WebGrid(row.plsst);
return nestgrd.GetHtml(
columns: nestgrd.Columns(
nestgrd.Column("FreePackageDetails", format: (item) => Html.ActionLink((string)item.Product.ToString(), "FreePackageDetails", new { id = item.PkId }, new { @class = "openDialog", data_dialog_id = "EmailDialog", data_dialog_title = "Details" })),
nestgrd.Column("Free Gift", format: (item) => Html.ActionLink((string)item.Product.ToString(), "FreeGiftViews", new { id = item.PkId }, new { @class = "openDialog", data_dialog_id = "EmailDialog", data_dialog_title = "Details" })),
nestgrd.Column("Qty", format: (item) => Html.ActionLink((string)item.Product.ToString(), "FreeGiftQuantityViews", new { id = item.PkId }, new { @class = "openDialog", data_dialog_id = "EmailDialog", data_dialog_title = "Details" }))
),
displayHeader: false
);
})
))
</div>
答案 0 :(得分:0)
不幸的是,你不能这样做。 WebGrid只会绑定到单个模型,因为列不是强类型的,所以不能引用父类。
解决方案是创建一个ViewModel,其中包含要在WebGrid中表示的所有数据,然后将WebGrid绑定到该ViewModel。