【发布时间】:2011-11-23 01:22:08
【问题描述】:
我正在使用 mvcContrib 生成一个网格,以允许用户通过键入搜索数据来过滤数据。在我的索引视图中呈现了几个部分视图:
这是处理搜索的局部视图:
@model CRMNPS.Models.PagedViewModel<CRMNPS.Models.NPSProcessed>
@using (Html.BeginForm("Index", "Home", FormMethod.Get))
{
<label>
Model Number: @Html.TextBox("searchWord" )
<br /><br />From Date: @Html.EditorFor(m => m.FromDate)
</label>
<label>
<Br /><br />To Date: @Html.EditorFor(m => m.ToDate)
</label>
<label>
<br /><br /> <input class="button" value="Search" type="submit" />
<br />
</label>
}
这是我的索引视图:
@model PagedViewModel <CRMNPS.Models.NPSProcessed>
@{
ViewBag.Title = "CRM Processed List";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Processed List</h2>
@{Html.RenderPartial("SearchBox");}
@{Html.RenderPartial("Pager", Model.PagedList);}
@Html.Grid(Model.PagedList).AutoGenerateColumns().Columns(column =>{
column.For(x => Html.ActionQueryLink(x.ModelNumber, "Edit", new { id = x.Id
})).Named("Id").InsertAt(1);
}).Sort(Model.GridSortOptions).Attributes(@class => "grid-style")
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { FromDate = Model.FromDate, ToDate = Model.ToDate, SearchWord = Model.SearchWord }))
{
<p>
<input class="button" value="Export to Excel" type="submit" />
</p>
}
在索引视图的底部,我在 Html.BeginForm 中使用 Formmethod.Post 提交了另一个。
调用此视图的 Index ActionResult 传递一个带有搜索条件的视图模型和一个 mvcContrib 使用的 IQueryable 对象。
当用户按下“导出到 Excel”按钮时,我想将选定的值传递回 Index actionresult HttpPost 控制器。 (FromDate、ToDate 和 SearchWord)
FromDate、ToDate 和 SearchWord 值总是返回 null。
我是 MVC 的新手,所以欢迎任何有建设性的 cmets。
谢谢
乔
【问题讨论】:
-
你看不到
<br>和&nbsp;&nbsp;&nbsp;足够了......
标签: c# asp.net-mvc-3 controller