View页默认是显示全部记录,筛选查询通过jQuery提交到Action查询,查询结果也正确,但如何将查询结果发送给当前View,并显示查询结果?View:
@using (Html.BeginForm("Index", "AdminUser", FormMethod.Post, new { name = "searchForm", id = "Form1" }))
{
<table border="0" cellpadding="0" cellspacing="0" width="98%">
<tr align="left">
<td style="width:100px;"><select id="GroupList" name="GroupList"></select></td>
<td style="width:110px;"><select id="GradeList" name="GradeList"></select></td>
<td style="width:200px;">用户名:<input type="text" id="userName" name="userName" /></td>
<td style="width:150px;">生日:<input type="text" id="userBirthday" name="userBirthday" class="Wdate" style="width:90px;" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:'true',maxDate:'%y-%M-%d'});" /></td>
<td><input type="button" value="查 找" onclick="Query()"
class="button0" onmouseover="this.className='button0_on'" onmouseout="this.className='button0'" /></td>
</tr>
</table>
}<table ... /> 这是显示列表的
Controller: public ActionResult Index(int iPageIndex = 1)
{
string sGroupID = Request["GroupList"];
string sGradeID = Request["GradeList"];
string sName = Request["userName"];
string sBirthday = Request["userBirthday"]; IQueryable<Web_User> uList = userBLL.GetList();
if (!string.IsNullOrEmpty(sGroupID)) uList = uList.Where(m => m.user_groupid == sGroupID);
if (!string.IsNullOrEmpty(sGradeID)) uList = uList.Where(m => m.user_gradeid == sGradeID);
if (!string.IsNullOrEmpty(sName)) uList = uList.Where(m => m.user_name.Contains(sName));
if (!string.IsNullOrEmpty(sBirthday)) uList = uList.Where(m => m.user_birthday == Convert.ToDateTime(sBirthday));
List<Web_User> userList = userBLL.GetList(uList.OrderByDescending(m => m.user_regdate), iPageIndex, 10); ViewBag.PageCount = userBLL.GetPageCount(uList, 10);
ViewBag.PageIndex = iPageIndex; return View(userList);
}控制器查得的结果(userList)是正确的,但View页面没有任何反应,怎么办?
@using (Html.BeginForm("Index", "AdminUser", FormMethod.Post, new { name = "searchForm", id = "Form1" }))
{
<table border="0" cellpadding="0" cellspacing="0" width="98%">
<tr align="left">
<td style="width:100px;"><select id="GroupList" name="GroupList"></select></td>
<td style="width:110px;"><select id="GradeList" name="GradeList"></select></td>
<td style="width:200px;">用户名:<input type="text" id="userName" name="userName" /></td>
<td style="width:150px;">生日:<input type="text" id="userBirthday" name="userBirthday" class="Wdate" style="width:90px;" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:'true',maxDate:'%y-%M-%d'});" /></td>
<td><input type="button" value="查 找" onclick="Query()"
class="button0" onmouseover="this.className='button0_on'" onmouseout="this.className='button0'" /></td>
</tr>
</table>
}<table ... /> 这是显示列表的
Controller: public ActionResult Index(int iPageIndex = 1)
{
string sGroupID = Request["GroupList"];
string sGradeID = Request["GradeList"];
string sName = Request["userName"];
string sBirthday = Request["userBirthday"]; IQueryable<Web_User> uList = userBLL.GetList();
if (!string.IsNullOrEmpty(sGroupID)) uList = uList.Where(m => m.user_groupid == sGroupID);
if (!string.IsNullOrEmpty(sGradeID)) uList = uList.Where(m => m.user_gradeid == sGradeID);
if (!string.IsNullOrEmpty(sName)) uList = uList.Where(m => m.user_name.Contains(sName));
if (!string.IsNullOrEmpty(sBirthday)) uList = uList.Where(m => m.user_birthday == Convert.ToDateTime(sBirthday));
List<Web_User> userList = userBLL.GetList(uList.OrderByDescending(m => m.user_regdate), iPageIndex, 10); ViewBag.PageCount = userBLL.GetPageCount(uList, 10);
ViewBag.PageIndex = iPageIndex; return View(userList);
}控制器查得的结果(userList)是正确的,但View页面没有任何反应,怎么办?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货