分页1

一.Ajax

// 重複項目削除
            for (int i = 0; i < recipeList.Count; i++)
            {
                for (int j = i + 1; j < recipeList.Count; j++)
                {
                    if (recipeList[i].materialName == recipeList[j].materialName && recipeList[i].materialVolume == recipeList[j].materialVolume)
                    {
                        recipeList[i].num++;
                        recipeList.RemoveAt(j);
                        j--;
                    }
                }
            }

            // ページ分け処理
            if (recipeList != null && recipeList.Count() > 0)
            {
                int pageCount = 0;
                if (recipeList.Count() % onePageCount == 0)
                {
                    pageCount = recipeList.Count() / onePageCount;
                }
                else
                {
                    pageCount = recipeList.Count() / onePageCount + 1;
                }
                model.pageCount = pageCount;

                if (pageNo <= pageCount)
                {
                    model.startItemNo = (pageNo - 1) * onePageCount;
                    if (pageNo == pageCount)
                    {
                        model.lastItemNo = recipeList.Count() - 1;
                    }
                    else
                    {
                        model.lastItemNo = pageNo * onePageCount - 1;
                    }
                    model.totalCount = recipeList.Count();

                    // Skip数量
                    int SkinCount = (pageNo - 1) * onePageCount;
                    model.RecipeMaterialList = recipeList.Skip(SkinCount).Take(onePageCount).ToList();
                }
            }

<div id="page-break">
                <ul class="breaklist">
                    @if (Model.pageNo > 1)
                    {
                        <li class="pageBack">@*<a class="glbPanelNew_r" href="/Genearea/RecipeMaterial/Result/?recipeId=@(Model.recipeId)&amp;no=@(Model.pageNo - 1)"">*@
                           <a class="glbPanelNew_r" href="javascript:getAjaxPageDate('recipeId=@(Model.recipeId)&no=@(Model.pageNo - 1)')">
                                <img width="12" alt="" src="http://www.cnblogs.com/http://www.cnblogs.com/Content/DnaDiet/img/sprites/arrow-l-01.png"></a></li>
                    }
                    else
                    {
                        <li class="pageBack"><a class="glbPanelNew_r" href="#">
                            <img width="12" alt="" src="http://www.cnblogs.com/http://www.cnblogs.com/Content/DnaDiet/img/sprites/arrow-l-02.png"></a></li>
                    }
                    <li class="pageNumber"><span>@(Model.startItemNo + 1)~@(Model.lastItemNo + 1)/@(Model.totalCount)</span></li>
                    @if (Model.pageNo < Model.pageCount)
                    {
                        <li class="pageNext">@*<a class="glbPanelNew_r" href="/Genearea/RecipeMaterial/Result/?recipeId=@(Model.recipeId)&amp;no=@(Model.pageNo + 1)">*@
                            <a class="glbPanelNew_r" href="javascript:getAjaxPageDate('recipeId=@(Model.recipeId)&no=@(Model.pageNo + 1)')">
                                <img width="12" alt="" src="http://www.cnblogs.com/http://www.cnblogs.com/Content/DnaDiet/img/sprites/arrow-r-01.png"></a></li>
                    }
                    else
                    {
                        <li class="pageNext"><a class="glbPanelNew_r" href="#">
                            <img width="12" alt="" src="http://www.cnblogs.com/http://www.cnblogs.com/Content/DnaDiet/img/sprites/arrow-r-02.png"></a></li>
                    }
                </ul>
            </div>
posted @ 2013-01-25 14:15  小水阿哥  阅读(128)  评论(0编辑  收藏  举报