Data does not change after i click paging link

Apr 8, 2010 at 8:26 PM

Need some advise...
I'm on MVC2, .net 4.0, VS2010, IIS 6.0
trying to use MVCPAGER.DLL to create paging links...


My problem is that the Paging Links are appearing correctly...
however... when I Click on link, page refreshes, URL changes, but the data stays the same.

I'm not sure what I'm missing...

I would be most grateful for any direction you could provide.

Here are the details of my app:

ROUTE:

routes.MapRoute("Instructors", "Instructor.aspx/Index/{id}/Page/{pageIndex}", new { controller = "Instructor", action = "Index", id = "", page = 1 });
 
PAGER:

<%=Html.Pager(this.ViewData.Model.getInstructors , null, "Instructors" , null)%>
 
CONTROLLER:
public ActionResult Index(Guid id, int? page)
        {

          InstructorListViewModel viewdata = new InstructorListViewModel(
                                repository.GetDistrictHeaderByDistrictGUID(id),
                                repository.GetInstructorsByDistrictGUID(id, page));
                          
            return View(viewdata);
          
        }

        
REPOSITORY:

 public PagedList<InstructorList> GetInstructorsByDistrictGUID(Guid District_Guid, int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
            int defaultPageSize = 15;
            
            return (from s in db.Schools
                    join d in db.Districts on s.District_GUID equals d.District_GUID
                    join i in db.Instructors on s.School_GUID equals i.School_GUID
                    join p in db.Persons on i.Instructor_GUID equals p.Person_GUID
                    join a in db.Addresses on i.Instructor_GUID equals a.Object_GUID
                    join z in db.Zip_Codes on a.Zip_Code equals z.ZipCode
                     where d.District_GUID == District_Guid
                     orderby s.School_Name, p.Person_Last_Name
                     select new InstructorList
                     {
                            s_GUID =    s.School_GUID,
                            s_Name =     s.School_Name,
                            i_GUID =     i.Instructor_GUID,
                            p_NAME =     p.Person_First_Name + ' ' + p.Person_Last_Name,
                            a_Street =     a.Street_Address,
                            a_City =     z.Zip_Code_City_Name,
                            a_State =     z.State_Code,
                            a_Zip =     a.Zip_Code

                     }).ToPagedList(currentPageIndex, defaultPageSize);
        }


Thanks in Advance,

-MARK-
putrtek@gmail.com

Apr 8, 2010 at 9:32 PM
Edited Apr 8, 2010 at 9:36 PM

ISSUE RESOLVED!

After using Phil Haack's Route Debugger, http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

I figured out that my Controller was wrong.

I changed THIS...

public ActionResult Index(Guid id, int? page)
{
InstructorListViewModel viewdata = new InstructorListViewModel(
repository.GetDistrictHeaderByDistrictGUID(id),
repository.GetInstructorsByDistrictGUID(id, page));
return View(viewdata);
}

 

TO THIS...

 

public ActionResult Index(Guid id, int? pageIndex)
{
InstructorListViewModel viewdata = new InstructorListViewModel(
repository.GetDistrictHeaderByDistrictGUID(id),
repository.GetInstructorsByDistrictGUID(id, pageIndex));

return View(viewdata);
}

Changes in RED

All is well...

-MARK-

 

Coordinator
Apr 9, 2010 at 2:32 PM

Glad to hear that you solved the problem yourself!