我有一些MVC3网格。
@grid.GetHtml(
tableStyle: "grid",
headerStyle: "CenteredHeader",
alternatingRowStyle: "alt",
columns: grid.Columns(
在该方法中,我通过一些通用 checkboxes
过滤数据。
[IsAuthenticated]
[HttpPost]
public ActionResult Movies(int? id, FormCollection formCollection)
{
当我尝试对已过滤的数据进行排序时问题apearas。我的意思是列标题URL没有任何参数,我也不能使用[HttpPost]。
有任何线索,当我点击这些复选框时,如何访问所选复选框或修改列标题网址?
此链接包含MVC3 Grid的列标题网址。
http://localhost:16349/MyWebsite/Movies/807?sort=TechnologyName&sortdir=DESC
谢谢!
P.S。代码
<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>