首页 新闻 会员 周边 捐助

asp.net mvc3 + dwz框架 搜索后分页问题

0
悬赏园豆:100 [已解决问题] 解决于 2012-07-10 21:25
 1 public ActionResult Index(int? pageNum, int? numPerPage, string keyword)
 2         {
 3             int pageIndex = pageNum.HasValue ? pageNum.Value : 1;
 4             int pageSize = numPerPage.HasValue && numPerPage.Value > 0 ? numPerPage.Value : 20;
 5             int recordCount = 0;
 6 
 7             BLL.AdminNavigation bllNav = new BLL.AdminNavigation();
 8             List<Model.AdminNavigation> list = bllNav.GetPage(pageSize, pageIndex, out recordCount, keyword);
 9 
10             ViewData["pageIndex"] = pageIndex;
11             ViewData["pageSize"] = pageSize;
12             ViewData["recordCount"] = recordCount;
13             ViewData["keyword"] = keyword;
14 
15             return View(list);
16         }

 

<form id="pagerForm" method="post" action="@Url.Action("Index")">
    <input type="hidden" name="pageNum" value="@ViewData["pageIndex"]" />
    <input type="hidden" name="numPerPage" value="@ViewData["pageSize"]" />
    </form>
    <div class="pageHeader">
        <form onsubmit="return navTabSearch(this);" action="@Url.Action("Index")" method="post">
        <div class="searchBar">
            <ul class="searchContent">
                <li>
                    <label>
                        导航名称:</label>
                    <input name="keyword" type="text" value="@ViewData["keyword"]" />
                </li>
            </ul>
            <div class="subBar">
                <ul>
                    <li>
                        <div class="buttonActive">
                            <div class="buttonContent">
                                <button type="submit">
                                    检索</button></div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
        </form>
    </div>
    <div class="pageContent">
        <div class="panelBar">
            <ul class="toolBar">
                <li><a class="add" href="demo_page4.html" target="navTab"><span>添加</span></a></li>
                <li><a class="delete" href="demo/common/ajaxDone.html?navID={navID}" target="ajaxTodo"
                    title="确定要删除吗?"><span>删除</span></a></li>
                <li class="line">line</li>
            </ul>
        </div>
        <table class="table" width="100%" layouth="138">
            <thead>
                <tr>
                    <th width="40">
                        <input type="checkbox" group="ids" class="checkboxCtrl">
                    </th>
                    <th>
                        编号
                    </th>
                    <th>
                        导航名称
                    </th>
                    <th>
                        父节点编号
                    </th>
                    <th>
                        链接地址
                    </th>
                    <th>
                        排序
                    </th>
                    <th width="120">
                        备注
                    </th>
                    <th width="70">
                        操作
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr target="navID" rel="@item.NavID">
                        <td>
                            <input name="ids" type="checkbox" value="@item.NavID" />
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.NavID)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.NavName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.ParentID)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.NavUrl)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Sort)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Remark)
                        </td>
                        <td>
                            <a title="查看" target="dialog" href="Student/testdetail.aspx?id="></a><a title="删除" target="ajaxTodo" href="../Navigation/NavDel/@item.NavID" class="btnDel">
                                删除</a> <a title="编辑" target="navTab" href="Student/testedit.aspx?id=" class="btnEdit">
                                    编辑</a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        <div class="panelBar">
            <div class="pages">
                <span>每页20条,共 @ViewData["recordCount"] 条</span>
            </div>
            <div class="pagination" targettype="navTab" totalcount="@ViewData["recordCount"]" numperpage="@ViewData["pageSize"]" pagenumshown="10"
                currentpage="@ViewData["pageIndex"]">
            </div>
        </div>
    </div>

代码如上 分页和搜索 单独都没什么问题

但是搜索后在分页时不能获取搜索条件的值

因为dwz框架的分页和搜索是分开2个form表单提交的

如何提交分页时获取搜索条件的值

暗尘掩月的主页 暗尘掩月 | 初学一级 | 园豆:183
提问于:2012-07-10 17:24
< >
分享
最佳答案
0

分页的代码在哪呢?这个你需要修改分页的代码。把你的ViewData["keyword"]值再post提交过去。

就是在你的“dwz框架的分页”的form里,弄一个隐藏表单项keyword ,值就是ViewData["keyword"]

收获园豆:100
owsir | 菜鸟二级 |园豆:481 | 2012-07-10 18:09
其他回答(1)
0

 <div class="pagination" targettype="navTab" totalcount="@ViewData["recordCount"]" numperpage="@ViewData["pageSize"]" pagenumshown="10"
                currentpage
="@ViewData["pageIndex"]">
            </div>

这一段是分页代码,你那有完整的代码么?

lakeyangjie | 园豆:202 (菜鸟二级) | 2012-09-30 01:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册