我有 2 个 WebGrid。我想使用属性 SelectedRow。在第一个 WebGrid 中运行良好,但第二个不是。
这是主视图 (WebGrid 1),这里称为包含第二个 WebGrid 的局部视图:
@model IEnumerable<RolesMVC3.Models.ESTUDENT>
@{
ViewBag.Title = "Index";
WebGrid grid = new WebGrid(Model);
}
<h2>Index</h2>
@using (Html.BeginForm())
{
@grid.GetHtml(fillEmptyRows: false,
alternatingRowStyle: "alternate",
headerStyle: "header",
tableStyle: "table",
selectedRowStyle: "selected",
mode: WebGridPagerModes.All,
columns: new[] {
grid.Column("IdEstudent", header: "ID"),
grid.Column("NameEstudent", header: "Name"),
grid.Column("LastNameEstudeNT", header: "Last Name"),
grid.Column( "", header: " ",format:@<text>@item.GetSelectLink("SELECT")</text>)
})
if (grid.HasSelection)
{
Html.RenderAction("Process", "Pass", new { id = grid.SelectedRow["IdEstudent"] });
}
}
这是第二个 WebGrid (WebGrid 2) 的局部视图。WebGrid 2 包含记录,但为什么 grid2.SelectedRow ["IdConsultation"] 为 NULL?
**Process.cshtml:**
@model IEnumerable<RolesMVC3.Areas.Manager.Models.ConsViewModel>
@{
WebGrid grid2 = new WebGrid(Model);
}
@grid2.GetHtml( fillEmptyRows: false,
alternatingRowStyle: "alternate",
headerStyle: "header",
tableStyle : "table",
selectedRowStyle: "selected",
mode: WebGridPagerModes.All,
columns: new [] {
grid2.Column("IdConsultation", header: "Consultation"),
grid2.Column("Idregister", header: "Register"),
grid2.Column( "", header: " ",format:@<text>@item.GetSelectLink("SELECT")</text>)
})
@if (grid2.HasSelection)
{
<input type="hidden" id="Consultation" name="Consultation" value="@grid2.SelectedRow["IdConsultation"]"/>
Html.RenderAction("EstudianiatesCJ1", "Sustitucion");
}
祝福