pagedlist

The SqlParameter is already contained by another SqlParameterCollection

﹥>﹥吖頭↗ 提交于 2019-12-25 07:35:48
问题 I'm using EF DbContext SqlQuery to get a list of paged objects using PagedList (https://github.com/TroyGoode/PagedList) and I'm getting the following error: "The SqlParameter is already contained by another SqlParameterCollection" Here's my repository code: var db = (DbContext)DataContext; const string sqlString = @" WITH UserFollowerList AS ( SELECT uf.FollowId FROM UserFollow uf WHERE uf.UserId = @UserId ) SELECT * FROM UserFollowerList uf INNER JOIN [User] u ON uf.FollowId = u.UserId WHERE

Unable to add to IPagedList object or transfer List<T> to IPagedList<T>

情到浓时终转凉″ 提交于 2019-12-24 01:24:46
问题 I'm using the Page List ASP MVC plugin to add paging to my View as my view model contains a list that gets a little out of control at time. However, I'm running into a few issues. The view model contains a List<T> of another model object. If I make one query to the database, I'm able to change the data type of this list from List<ZipCodeTerritory> to IPagedList<ZipCodeTerritory> , then simply follow the documentation to load the list from the query like so: View Model public IPagedList

Use StaticPagedList with PagedListRenderOptions

你说的曾经没有我的故事 提交于 2019-12-23 22:59:51
问题 Using PagedList of MVC. Not able to get Property: PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.IfNeeded } Note that I'm using StaticPagedList not PagedListPager . My Requirement is : pagedlist-pagination Not able to find syntax to use StaticPagedList with PagedListRenderOptions 回答1: Pass the paging meta data as separate property and construct the IPagedList in the view. Like this: public class PagedClientViewModel { public int? Page { get; set; } public List

AJAX request isn't recognized as such

二次信任 提交于 2019-12-23 22:08:09
问题 I have a list of items which can be searched and the page has pagination. When a search query is entered the partial view gets loaded correctly (AJAX). However, when you use the pagination, it fires a non-ajax request (entire page gets reloaded and no XmlHttpRequest flag in the header). What causes this? $(function () { // Adds Ajax to pagination of search results var getPage = function () { var $a = $(this); var options = { url: $a.attr("href"), type: "get", data: $("form").serialize() }; $

Using @Html.DisplayNameFor() with PagedList

前提是你 提交于 2019-12-20 08:35:06
问题 I've been trying out the PagedList package to get paging for my index views. Everything was going well, and at the controller level everything is working fine, it only displays 5 records per page, and displays the appropriate page based on the querystring. My problem is in the view. I changed the @Model to PagedList.IPagedList so I could access the Model.HasNextPage and other properties, but now the @Html.DisplayNameFor(model => model.ItemName) are no longer working. I get this error:

toPagedList() order differs from the LINQ order by clause

孤街醉人 提交于 2019-12-19 22:49:10
问题 I have a small application that displays a list of shortURLs to a user. I'm using ASP.NET MVC3, Entity Framework, and an Oracle backend. I'm also using the PagedList library by Troy Goode (https://github.com/TroyGoode/PagedList) I want the user to see the very last entry first, similar to how blog comments are ordered. To do this I added an "orderby descending" clause to the LINQ statement: var links = from l in db.LINKS orderby l.ID descending select l; In debug the "links" object is ordered

PagedList error: The method 'OrderBy' must be called before the method 'Skip'

↘锁芯ラ 提交于 2019-12-18 14:45:53
问题 Here's the full error message: The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip' In the "PurchaseOrderController" I have added this code to the index method: // GET: PurchaseOrder public ActionResult Index(int? page) { return View(db.PurchaseOrders.ToPagedList(page ?? 1, 3)); } Also in the Index View for "PurchaseOrders" I have added this code: @using PagedList; @using PagedList.Mvc; @model IPagedList

How do I add a querystring when using the MVC PagedList?

柔情痞子 提交于 2019-12-14 04:08:07
问题 How would I go about adding a query string to the Razor Helper PagedListPager below ? @Html.PagedListPager( (IPagedList)Model.PartsList, page => Url.Action("Index", new { page }) ) 回答1: You don't add query parameters in PagedListPager , you do them in Url.Action . Below is an updated version of your code, I've added a query parameter tag . Url.Action("Index", new { page, tag = 'asp' }) The URL would generate the following query string ?page=1&tag=asp Here is the same Url.Action within

Working with PagedList and Membership

元气小坏坏 提交于 2019-12-14 02:15:44
问题 I've been playing around with Troy Goode's PagedList http://pagedlist.codeplex.com/. I was wondering if anyone has gotten it to work with the built in asp.net Membership piece? I have over 8000 users so I need to be able to page thru the User list. using a line like this in my memberhsip controller doesn't work. It wont compile. Membership.GetAllUsers().ToPagedList(currentPageIndex, defaultPageSize); Appreciate any guidance in this area... TIA -MARK- putrtek@gmail.com 回答1: Membership

MVC 4 Using Paged List in a partial View

僤鯓⒐⒋嵵緔 提交于 2019-12-13 13:25:57
问题 I am trying to implement PagedList in a partial view. Describing the view setup. I have Controller A with ViewA . This is the parent view and has its own model. Then I have Controller B with PartialViewB and has its own model as well. Then I have a Div in ViewA that will be used to display the PartialViewB . I can load in PartialViewB after hitting a button and then hide the view after hitting the button again. Within the PartialViewB is the PagedList. Hitting the next page button loads the