不方便的WebGrid选定行的MVC3(Inconvenient webgrid selected row MVC 3)
我有两个的WebGrid。我想使用属性SelectedRow。在第一的WebGrid效果很好,但第二个不好。这是主视图(WebGrid1),这里被称为局部视图,其中包含第二的WebGrid:(英文原文:I have two WebGrid. I want to use the property SelectedRow. in the first WebGrid works well, but the second not.
This is the main view (WebGrid 1), here called a partial view that contains the second 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(的WebGrid2)局部视图。的WebGrid2包含的记录,但为什么grid2.SelectedRow[的“IdConsultation”]为NULL?(英文原文:This is a partial view of the second WebGrid (WebGrid 2). The WebGrid 2 contains records, but Why grid2.SelectedRow ["IdConsultation"] is 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");
}
补充:.NET技术 , ASP.NET