I've got simple action in which I make a request to web service to get a LIST<> of articles for specific group.
Then using pagedList (and specifying the desired page and page number) of course I specify the subset of that list I want to take. The problem is : the article for specific group can be thousand for example - and getting the info for all of them from the web service takes a lot of time and even sometimes crushes (when the articles are above 1000)
Is there a way to get the articles only for the specific page and still to use pagedList because I see that unfortunately we have to call ToPagedList method for the whole collection.
public virtual ActionResult ImportShow(String id, int? menuID, string articlegroupID, string menuforHistory,int? counter,int?page,int? pageSize,string articleDescr, int? ArticleID)
{
List<WebServiceBeaMenu> standartList = ebServiceBea.GetArticle(Convert.ToInt32(menuID), articlegroupID, "", articleDescr);
IPagedList<WebServiceBeaMenu> p_ProductsShow = standartList.ToPagedList(actualpage,actualPageSize);
p_GroupMenu.ProductMenu = p_ProductsShow;
p_GroupMenu.MenuHistory = p_GetMenuHistory.ToList();
p_GroupMenu.MenuLeft = p_GetMenuLeft.ToList();
return PartialView("ImportShow", p_GroupMenu);
}
}
here is my view
@model MvcBeaWeb.GroupMenu
@for (int i = 0; i < Model.ProductMenu.Count; i++)
{
<div>
var item = Model.ProductMenu[i];
@Html.PagedListPager(Model.ProductMenu, page => Url.Action("ImportShow", new { id = Model.LanguageName, menuID = @Session["men"], articlegroupID = Session["article"], articleDescr = Session["articleDescr"], pageSize = Session["pageSize"], page }))
</div>
You should rewrite
.GetArticle()
Or replace it with whith somethink like.GetPagedArticle()
if you have access to WebService. This methid should have all paging params. That's the only way i think. Your.GetArticle()
method should return object like this:Where
Elements
should be not all elements, but only paged one.