TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Martin Jeremic
NA
1
5.1k
pagination problem with asp.net and partial views
Feb 25 2014 4:31 AM
I have viewmodel with 3 classes
public IEnumerable<Nazivi_grupa> ngrupa { get; set; }
public IEnumerable<Grupe_radova> gradova { get; set; }
public IEnumerable<Pozicije> pozicije { get; set; }
partial view partPozicijeView.cshtml
@model PagedList.IPagedList<WebApplication3.ViewModels.mainViewModel>
@using PagedList.Mvc;
@{ some code to show table }
and main view index.cshtml
@model WebApplication3.ViewModels.mainViewModel
@using PagedList.Mvc;
<tr>
<td>Category </td>
<td> :</td>
<td><div id="KnjigeNormativa">@Html.Partial("partKnjigeNormativaView", Model)</div> </td>
</tr>
<tr>
<td>Sub - Category </td>
<td> :</td>
<td><div id="GrupeRadova"> @Html.Partial("partGrupeRadovaView", Model)</div></td>
</tr>
<tr>
<td>Products </td>
<td> :</td>
<td><div id="Pozicije"> @Html.Partial("partPozicijeView", Model)</div></td>
</tr>
that calls 3 partial views to show first 2 tables in cascaded dropdowns and 3rd one (pozicije) in a table.
Now i'm trying to add pagination to that table, but no matter what, i'm getting an error
The model item passed into the dictionary is of type 'WebApplication3.ViewModels.mainViewModel', but this dictionary requires a model item of type 'PagedList.IPagedList`1[WebApplication3.ViewModels.mainViewModel]'.
on 3rd partial view call.
Here's also code for controller
public ActionResult SelectPozicije(string SelectedPosId, int? pnum)
{
int pageNumber = (pnum ?? 1);
mainViewModel mv = new mainViewModel();
mv.pozicije = new List<Pozicije>();
// mv.pozicije = (from p in mainViewModel.getPozicije()
// where p.grupa == SelectedPosId
// select p).ToPagedList(pageNumber, 25);
mv.pozicije = (from p in mainViewModel.getPozicije()
where p.grupa == SelectedPosId
select p).ToList();
return PartialView("partPozicijeView", mv);
}
I tried (commented code) to return .ToPagedList() but no success...
can someone point me how to do this?
Reply
Answers (
0
)
Pdf file creation and automatic trigger that Pdf to peoples
can not get databases when creating connection string