1

我想hide/show打开但不能在内部视图中进行buttoncondition

@{
    ViewBag.Title = "Mapping";
    WebGrid grid = null;
    if (ViewBag.Mappings != null)
    {
        grid = new WebGrid(source: ViewBag.Mappings,
                                defaultSort: "Id",
                                canPage: true,
                                canSort: true,
                                rowsPerPage: 10);
    }
}
<h3>@ViewData["Message"]</h3>
@if (grid != null)
{
    @grid.GetHtml(
                tableStyle: "grid",
                headerStyle: "head",
                alternatingRowStyle: "alt",
                columns: grid.Columns(
    grid.Column("", header: null, format: @<text>@Html.ActionLink("Edit", "Index", new { uid = (Guid)item.id, userAction = "Edit" }, new { @class = "edit" })
    @Html.ActionLink("Delete", "Index", new { uid = (Guid)item.id, userAction = "Delete" }, new { @class = "Delete" })</text>),
                                            grid.Column("PricingSecurityID"),
                                            grid.Column("CUSIP"),
                                            grid.Column("Calculation")
                                          )

                )
}

if(@ViewBag.Mappings != null)
  {    
@Html.ActionLink("Update", "Index", new { userAction = "Update" }, new { @class = "Update" })
}

在上面的视图中,如果ViewBag.Mappings != null我正在填充 webgrid。如果填充了 webgrid,我需要Update在 webgrid 下显示一个按钮,但是在条件下我哪里出错了?

4

1 回答 1

2

从底部移动第 4 行的“@”:

前:

if(@ViewBag.Mappings != null)

后:

@if(ViewBag.Mappings != null)
于 2012-04-20T14:57:52.813 回答