2011-01-28 11 views
1

見つからすることはできませんこれは私がMVC2ページ付け問題、参照

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<FYP_MVC_SDP_Assignment.Helpers.PaginatedList<Member>>" %> 

を考えたから、ここでそれはメンバー

のインデックスに位置NerdDinner

から私のページ付けのコードの参照
<% if (Model.HasPreviousPage) { %> 
    <%: Html.RouteLink("<<<", 
         "Member", 
         new {Page=Model.pageindex -1}) %> 
<% } %> 
<% if(Model.HasNextPage) { %> 
<%: Html.RouteLink(">>>", 
       "Member", 
       new {Page =Model.PageIndex +1})%> 
<% } %> 

ですがthaの主な問題が来るところであります

これは(.../Helpers/PaginateList.cs)にあるヘルパーです

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Mvc; 
using FYP_MVC_SDP_Assignment.Models; 
using System.ComponentModel.DataAnnotations; 

namespace FYP_MVC_SDP_Assignment.Controllers 
{ 
public class PaginatedList<T> : List<T> 
{ 
public int PageIndex { get; private set; } 
public int PageSize { get; private set; } 
public int TotalCount { get; private set; } 
public int TotalPages { get; private set; } 

public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize) 
{ 
    PageIndex = pageIndex; 
    PageSize = pageSize; 
    TotalCount = source.Count(); 
    TotalPages = (int)Math.Ceiling(TotalCount/(double)PageSize); 
    this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize)); 
} 

public bool HasPreviousPage 
{ 
    get 
    { 
     return (PageIndex > 0); 
    } 
} 

public bool HasNextPage 
{ 
    get 
    { 
     return (PageIndex + 1 < TotalPages); 
    } 
} 

} }

これは、これは私が続けるエラーが取得し、試されますがこれは私のルート

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Mvc; 
using System.Web.Routing; 

namespace FYP_MVC_SDP_Assignment 
{ 
// Note: For instructions on enabling IIS6 or IIS7 classic mode, 
// visit http://go.microsoft.com/?LinkId=9394801 

public class MvcApplication : System.Web.HttpApplication 
{ 
    public static void RegisterRoutes(RouteCollection routes) 
    { 
     routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

     routes.MapRoute(
      "Member", 
      "Member/page/{page}", 
      new {controller = "Member", action ="Index"} 
     ); 

     routes.MapRoute(
      "Default", // Route name 
      "{controller}/{action}/{id}", // URL with parameters 
      new { controller = "Home", action = "Index", id = UrlParameter.Optional }   // Parameter defaults 
     );                         

    } 

    protected void Application_Start() 
    { 
     AreaRegistration.RegisterAllAreas(); 

     RegisterRoutes(RouteTable.Routes); 
    } 
} 

}

である私のメンバーインデックスコントローラー

 public ActionResult Index(int page=0) 
    { 
     const int pageSize = 8; 
     var members = clubmemberrepository.FindAllMember(); 
     var paginatedMember = new PaginatedList<tblMember> (members, 
      page, 
      pageSize); 
     return View(paginatedMember); 
    } 

ですstackoverflowからのソリューションを介しても、まだ解決不可能...誰もが私から助けることができたs iが

Server Error in '/' Application. 

Compilation Error 

Description: An error occurred during the compilation of a resource required to service  this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'FYP_MVC_SDP_Assignment' (are you missing an assembly reference?) 

Source Error: 


Line 170:  
Line 171: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()] 
Line 172: public class views_member_index_aspx : System.Web.Mvc.ViewPage<FYP_MVC_SDP_Assignment.Helpers.PaginatedList<Member>>, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler { 
Line 173:   
Line 174:  private static bool @__initialized; 

Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\eeab298d\fa291c0d\App_Web_index.aspx.7979c542.cpekphek.0.cs Line: 172 

ドメインアドレスこのERRORへのアクセス= http://localhost:8219/Member

答えて

1

PaginatedListFYP_MVC_SDP_Assignment.Controllers namesoaceであることをapears(ただし....割り当てXD

エラーのために急いでする必要がありながら、ビューに宣言されているSDP_Assignment.Helpers.PaginatedList名前空間には含まれていません)。

+0

私はYP_MVC_SDP_Assignment.Helpers.PaginatedListに変更しようとしましたが、エラーはまだ続きます。=助けてください...かなりラッシュ@。@ Thx = D – 1myb

+0

いいえ、最初の行のビュー自体には、 「継承=」System.Web.Mvc.ViewPage > "' –

+0

ありがとう= D最後に解決された^^気分がいい〜 – 1myb