我有一些 MVC3 网格。
@grid.GetHtml(
tableStyle: "grid",
headerStyle: "CenteredHeader",
alternatingRowStyle: "alt",
columns: grid.Columns(
在该方法中,我通过一些通用 checkboxes
的 .
[IsAuthenticated]
[HttpPost]
public ActionResult Movies(int? id, FormCollection formCollection)
{
当我尝试对已过滤的数据进行排序时,问题出现了。我的意思是列标题 URL 没有任何参数,我也不能使用 [HttpPost]。
当我单击这些复选框时,任何线索如何访问选定的复选框或修改列标题 URL?
此链接具有 MVC3 Grid 的列标题 url。
http://localhost:16349/MyWebsite/Movies/807?sort=TechnologyName&sortdir=DESC
谢谢!
PS 代码
<h2>
<a class="mainmenu" href="@Url.Action("Index", "Home/Areas")">Areas\</a><a class="mainmenu"href="@Url.Action("Index", "BoxOffice")">Box
Office\</a><span class="currentmenu">Cinema @ViewBag.ChainName</span></h2>
@{
var grid = new WebGrid(source: Model,
defaultSort: "MovieName",
rowsPerPage: 30);
}
@using (Html.BeginForm())
{
<fieldset>
<legend>Fecha de inicio y de finalización</legend>Fecha de inicio
<input type="text" id="startDate" size="10" class="datepicker" autocomplete="off" name="startDate" value="@ViewBag.StartDate" />
Fecha de finalización
<input type="text" id="endDate" size="10" class="datepicker" autocomplete="off" name="endDate" value="@ViewBag.EndDate"/>
<input type="submit" value="Buscar" class="button" />
@if (ViewBag.TechnologyNames != null)
{
<div style="margin: 8px;">
<b>Tecnologias</b>
@if (Session["TechList"] == null)
{
<input type="checkbox" name="option_all" id="checkbox_all" checked="checked" value="-1" /> <label>Todos</label>
foreach (var technologyName in ViewBag.TechnologyNames)
{
if (!technologyName.TechnologyID.ToString().Equals("-1"))
{
<input type="checkbox" name="option_@(technologyName.TechnologyID)" id="checkbox_@(technologyName.TechnologyID)"
value="@technologyName.TechnologyID" /> @technologyName.Name
}
}
}
else
{
var lst = (List<string>)Session["TechList"];
if (lst.Contains("-1"))
{
<input type="checkbox" name="option_all" id="checkbox_all" checked="checked" value="-1" /> <label>Todos</label>
}
else
{
<input type="checkbox" name="option_all" id="checkbox_all" value="-1" /> <label>Todos</label>
}
foreach (var technologyName in ViewBag.TechnologyNames)
{
bool isSelected = false;
foreach (var t in lst)
{
string n = technologyName.TechnologyID.ToString();
if (n.Equals(t))
{
isSelected = true;
break;
}
}
if (isSelected)
{
if (!technologyName.TechnologyID.ToString().Equals("-1"))
{
<input checked="checked" type="checkbox" name="option_@(technologyName.TechnologyID)" id="checkbox_@(technologyName.TechnologyID)"
value="@technologyName.TechnologyID" /> @technologyName.Name
}
}
else
{
if (!technologyName.TechnologyID.ToString().Equals("-1"))
{
<input type="checkbox" name="option_@(technologyName.TechnologyID)" id="checkbox_@(technologyName.TechnologyID)"
value="@technologyName.TechnologyID" /> @technologyName.Name
}
}
}
}
</div>
}
</fieldset>
}
<br />
<div id="grid">
@if (Model != null)
{
@grid.GetHtml(
tableStyle: "grid",
headerStyle: "CenteredHeader",
alternatingRowStyle: "alt",
columns: grid.Columns(
grid.Column(format: (item) => Html.ActionLink("Detalles", "Movie", new { id = item.MovieID })),
grid.Column("MovieName", "Pelicula"),
grid.Column("TechnologyName", "Tecnologia"),
grid.Column("Visitors", "Espect.", style: "CenteredNumbers"),
grid.Column("TotalSum2", "Monto", format: (item) => item.TotalSum2.ToString("#,0.00"), style: "CenteredNumbers"),
grid.Column("MoviePromedio", "TP", format: (item) => item.MoviePromedio.ToString("#,0.00"), style: "CenteredNumbers"),
grid.Column(format: (item) => Html.ActionLink("Comparativo por complejo", "Compare", new { id = item.MovieID }))
)
)
}
</div>