int _pageSize = 5;
int _skip = 0;
void OnSearchSpecificationChanged()
{
var x = q1.OrderBy(this._sort) //q1 is a linq query
.Skip(_skip)
.Take(_pageSize);
SearchResults = x.ToList();
}
SearchResults has 8 items, so it has 2 pages. all is well for the first page (5 items are shown), but when i click button 'next' or '2' (i have to click it twice, first time nothing happens) 3 items are shown, but the same ones as on the first page (first
3 from the first page).
pacoss
Member
1 Points
25 Posts
DataPager and ListView not working together
Dec 16, 2012 10:52 AM|LINK
this is the first time i use DataPager and ListView so i need help to configure datapager to work with this datasource. here is my code:
<asp:DataPager ID="DataPagerUp" runat="server" PageSize="5" PagedControlID="lvSearchResults" > <Fields> <asp:NextPreviousPagerField ButtonType="Image" ShowNextPageButton="False" PreviousPageImageUrl="~/images/buttons/btnPrevious21.png" /> <asp:NumericPagerField /> <asp:NextPreviousPagerField ButtonType="Image" ShowPreviousPageButton="False" NextPageImageUrl="~/images/buttons/btnNext21.png" /> </Fields> </asp:DataPager> <asp:ListView ID="lvSearchResults" runat="server" DataSource='<%# SearchResults %>'> <ItemTemplate> <RE:SearchResultItem ID="SearchResultItem" runat="server" ResultItem="<%# Container.DataItem %>" /> </ItemTemplate> </asp:ListView>datasource is as follows:
int _pageSize = 5; int _skip = 0; void OnSearchSpecificationChanged() { var x = q1.OrderBy(this._sort) //q1 is a linq query .Skip(_skip) .Take(_pageSize); SearchResults = x.ToList(); }SearchResults has 8 items, so it has 2 pages. all is well for the first page (5 items are shown), but when i click button 'next' or '2' (i have to click it twice, first time nothing happens) 3 items are shown, but the same ones as on the first page (first 3 from the first page).
vijay_myl
Contributor
5070 Points
1068 Posts
Re: DataPager and ListView not working together
Dec 16, 2012 11:31 AM|LINK
Hi..
Refer the below link to ue datapager control in ListView
http://www.dotnetcode.in/2012/10/datapager-control-in-aspnet.html
My .NET blog
Submit Article
pacoss
Member
1 Points
25 Posts
Re: DataPager and ListView not working together
Dec 16, 2012 11:46 AM|LINK
thanks a lot ! it works.