Repeater - Paging In C# Without A Database?
Aug 15, 2010
I have a page on my ASP.NET site that has a Repeater control to show posts from members of the site.
At the moment I am storing the data for the posts in an XML file and then caching it within the site inside custom objects.
So I have:
public class MemberPost
{
public string Title { get; set; }
public string Text { get; set; }
public string Name { get; set; }
public DateTime Date { get; set; }
public List<string> Pictures { get; set; }
}
And:
public class MemberPosts : List<MemberPost>
{
}
I'm able to set the data source of the repeater to an instance of MemberPosts and it all works as expected, but I want to add paging for when more posts are added.
All the examples I find seem to involve having the data to be paged in a database - is there any way I can bind the repeater or another similar control to my in-memory MemberPosts collection and have it implement paging for me?
View 3 Replies
Similar Messages:
Oct 22, 2010
Tell me how can i avoid reconnection to database while paging in repeater?
View 1 Replies
Jul 12, 2010
I have repeater in which I have 2 hyperlink in the footer of the repeater and I want that the hyperlink can navigate from the page_load
View 2 Replies
Jan 2, 2011
I've been looking for a good tutorial to teach me how to make a customized Paging control with a simple DataBound control like Repeater to implement a high performance paging feature. I've found a lot of articles about that issue, but non of them was a complete answer. Paging of Large Resultsets in ASP.NET. This one is awesome, with statistics and great comparison between the different methods of doing so, but the problem is it's too old before SQL Server had it's new function ROW_NUMBER() N-Layered Web Applications with ASP.NET 3.5 Part 4: Sorting, Paging and Filtering (The Database Paging Section and ignore the rest)
This one is almost perfect, but he used the grid's existing paging feature with a customized Method for paging, instead of a repeater. Custom SEO friendly paging with ASP.NET Repeater or DataList control I think this one is WAY too complicated, and things can get done easier. I'm using SQL, Items Repeater (with direct binding in the code-behind with no datasources used), PageNumbers repeater (which will have a link as an ItemTemplate to pass querystring so the used method could retrieve the next portion of Items), A Label to hold the current page number and title.
I've been trying to implement the example on N-Layered Web Applications with ASP.NET 3.5 Part 4: Sorting, Paging and Filtering (The Database Paging Section and ignore the rest). So far I've created a SQL command in my Data Access Lyaer that looks like this: WITH Records AS ( SELECT ItemId, ItemName, ROW_NUMBER() OVER ORDER BY ItemId) AS 'RowNumber' FROM Items) SELECT * FROM Records WHERE (RowNumber BETWEEN (@startIndex) AND @startIndex + @pageSize - 1)
View 1 Replies
Feb 26, 2010
I'm doing a webpage with a search that brings a lot of information from MSSQL. What I did is a stored procedure that return only the page to be seen on the website. Right now I'm working on the paging as I need to show something similar than google. If you are at page 1 they show first 10 pages and if you are at page 19 they show since page 9 to 28. I think the best option to show the page numbers is using a linkbutton inside a repeater. The problem that I have now is that I do not know the best way to take the page number at postback.
Doing a quick sample I assigned an ArrayList to repeater.datasource:
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandArgument="<%# Container.DataItem %>"><%# Container.DataItem %></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
<asp:LinkButton ID="LinkButton2" runat="server" CommandArgument="4654">Test #1</asp:LinkButton>
At my Default.aspx.cs file I have the next code
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack)
{
string x = LinkButton2.CommandArgument;
//string y = LinkButton1.CommandArgument;
//I know this line will not work since the Linkbutton1 is inside the Repeater.
}
What Shall I do to make it works? Does anyone has a better solution for this paging?
View 3 Replies
Aug 19, 2013
I need to know how to create paging on Repeater??
View 1 Replies
Jun 16, 2013
i don't from where to start ...
View 1 Replies
Jan 21, 2010
Since there is no implicit property for paging is there is any other way to achieve paging in Repeater Control
View 2 Replies
Feb 4, 2011
How to implement Paging in repeater control.
View 3 Replies
Jan 29, 2010
as question i asked (C#)
View 4 Replies
Apr 30, 2013
This is my situation:
I use prettyPhoto to display images from database. The images are displayed in a Repeater control with paging enabled, and with page size set to 3.
Everything works fine, the gallery loads up, I can go through pictures. But, prettyPhoto loads only 3 pictures at a time. So if I get 12 pictures from the database, I get 4 pages. So every time I have to view pictures from Page1, close the gallery, click the Next button that displays Page2 and so on.
I understand that this is happening because I set the PageSize to 3. I'm not sure how to "tell" prettyPhoto that there are actually more photos.
This is how I bind the Repeater to the datasource:
vb.net Code:
Dim Pds1 as New PagedDataSource()Pds1.DataSource = dsPictures.Tables(0).DefaultViewPds1.AllowPaging = TruePds1.CurrentPageIndex = CurrentPage Repeater3.DataSource = Pds1Repeater3.DataBind
This is the HTML for the page that uses the Repeater and gallery:
vb.net Code:
<a href = '<%#DataBinder.Eval(Container, "DataItem.newsPictureURL")%>' rel="prettyPhoto[Repeater3]" title = '<%#DataBinder.Eval(Container, "DataItem.newsPictureCaption")%><img id="icons" src = '<%#DataBinder.Eval(Container, "DataItem.newsPictureLocation")%>' alt = '<%#DataBinder.Eval(Container, "DataItem.newsPictureDesc")%>' />
As you can see, I use rel="prettyPhoto[Repeater3]" where Repeater3 is the name of the gallery, or DataSource.
I know it is hard to figure out anything with out inspecting the prettyPhoto source (jQuery).
View 1 Replies
Aug 17, 2010
How to maintain selected CheckBoxes' states in different pages inside the Repeater control and list out the selected checkboxes values.
View 2 Replies
Jul 1, 2010
I am trying to experiment with things as a beginner and want to use paging in Repeater Control. Since Repeater control is light weight, I want to use that. I have heard of two methods: PagedDataSource class and the other that I dont remember. I wanted to attempt both of them. How do I proceed?
View 2 Replies
Aug 2, 2010
I've got a repeater control containing comments. I'm about to implement ajax paging to it. I was opting to use the updatepanel (conditionally) for this thing, but I guess it's going to get kinda slow in production environment (Each time about 20 rows will be visible). I want to keep the repeater control since it contains other controls as well so I can't use a js (templates)/json approach.
View 1 Replies
Apr 19, 2010
im using repeater ann chilg repeater
html part is like this
<tr>
<td valign="top" style="background: url(images/welcomemid.jpg); width: 638px; height: 570px;">
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>....
View 1 Replies
Mar 11, 2010
some code or tutorial(easy to understand) for learning how to do paging in repeater.
i m learning asp.net.
View 5 Replies
Feb 28, 2012
I am using a custom membership provider. I needed to bind a repeater to a membershipusercollection but the only way I could think of was this:
There is no method to return a lcollection of membership users by userid. I basically have a friends table with a userid and a frienduserid field. both are foreign keys to the user table. So say I am userid 1 and I have two friends userid 2 and userid 3.
I needed to get a collection of membership users who are my friends (user 2 and 3)
So I did this:
Code:
Dim lstAccountIDs As List(Of Integer) = bl.GetFriendsAccountByUserID(iUser)
Dim mUsers As New MembershipUserCollection
For Each a In lstAccountIDs
mUsers.Add(Membership.GetUser(a))
Next
I get their id's and add them to to list(of Integer) then I loop through the list and get the particular user by id and add them to a membershipusercollection object.
I now need to add paging to my repeater control that uses that collection as a datasource. However the membership provider doesn't give me the ability to specify a pageindex or pagesize etc. It gives me those options in the GetAllUsers function but I need it to work in the above scenario.
View 1 Replies
Oct 27, 2013
How to create asp repeater with paging like this format
1 2 3 4 5 ...NEXT >>
I got a solution [Code] ..... but if this method is not effective if our table content >500
i.e. 1 2 3 4 5 6 7 8 9 10
View 1 Replies
Feb 25, 2016
Design page :
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%#Eval("ProductName")%>
</ItemTemplate>
</asp:Repeater><br />
<asp:LinkButton ID="lbPrevious" runat="server" Enabled="false">Previous page</asp:LinkButton>
<asp:LinkButton ID="lbNext" runat="server">Next page</asp:LinkButton>
Code behind file
using System;
// We need these namespaces imported to work easier with database
using System.Data;
using System.Data.SqlClient;
// Here is PagedDataSource class located
using System.Web.UI.WebControls;
[Code] .....
Record loaded into control but when i press next button then next 10 record showing properly but when i want to see another next record then it shows same record.
e.g. i have 40 records in my db then first time it shows 1 to 10 record
when i press next button then it shows 11 - 20 records
again i press next button then it shows 11-20 records instead of 21-30 records...
View 1 Replies
Nov 29, 2010
edit this code so i get the paging in a dropdown, where the sites ar showed as 1 of x, 2 of x and so on where x if the all the sites/pages.
[Code]....
View 3 Replies
Oct 29, 2010
how can i maintain the selected checkbox value in the repeater when i do a paging to a next page? While i go back to the previous page, the checkbox value that i have selected is still remain?
View 3 Replies
Jan 28, 2011
I want to do pagination in repeater control.
I am using repeater.Datasource = objectDataSource.
and objectdatasource is having generic list data.
When i try to cast objectdatasource to dataview ...i am getting exception saying "casting
Collections Generic List cannot be casted to Dataview".
Can anyone tell me easy way to do Repeater Pagination in the above mentioned case
View 4 Replies
May 3, 2010
I have a strange problem. I have made a PagedRepeater control, which inherits from the Repeater, from a tutorial I saw here: http://www.4guysfromrolla.com/articles/020905-1.aspx. It's in VB and I'm in C#, and it didn't quite have all the features I was lookingfor, so, I've modified it quite a bit. I added support for a SqlDataSource control, as well. The only problem is, that it always returns the first item from the SqlDataSource, even when the CurrentPageIndex on the PagedDataSource is set to a different value.
View 1 Replies
Jan 31, 2010
I need some code to a alphabetic paging in a repeater. the code should be in linq / c #.
View 3 Replies
Feb 3, 2010
I have a Custom Repeater control that inherits from Repeater and has paging functionality, however when I click the next page button the first time it refreshes the control but does not change the page, if I click it again after that it changes page perfectly. I know what the issue is, when I click the next button it does a postback, then the data is bound to the repeater, and then after that the NextButton Event is handled.
Is there any way I can change the order of the page load events?? Or force the repeater to reload again after the event is handled?? I've included my Custom Repeater class bellow:
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Data;
using System.Collections;
using System;
namespace ASPresentation.Controls
{
[ToolboxData("<cc:PagedRepeater runat=server></cc:PagedRepeater>")]
public class PagedRepeater : Repeater
{
public int PageSize { get; set; }
public int CurrentPageIndex
{
get
{
return Convert.ToInt16(Page.Session["ProjectIndex"]);
}
set
{
Page.Session.Add("ProjectIndex", value);
}
}
public PagedDataSource pagedData = new PagedDataSource();
LinkButton NextBtn = new LinkButton();
LinkButton PrevBtn = new LinkButton();
public bool IsLastPage
{
get
{
return pagedData.IsLastPage;
}
}
public bool IsFirstPage
{
get
{
return pagedData.IsFirstPage;
}
}
public override object DataSource
{
get
{
return base.DataSource;
}
set
{
pagedData.DataSource = (IEnumerable)value;
}
}
protected void NextButtonClick(object sender, EventArgs e)
{
if (!IsLastPage)
{
CurrentPageIndex++;
}
}
protected void PrevButtonClick(object sender, EventArgs e)
{
if (!IsFirstPage)
{
CurrentPageIndex--;
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
NextBtn.Text = "Next";
PrevBtn.Text = "Prev";
NextBtn.Click += new EventHandler(NextButtonClick);
PrevBtn.Click += new EventHandler(PrevButtonClick);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
base.Controls.Add(PrevBtn);
base.Controls.Add(NextBtn);
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
}
public override void DataBind()
{
pagedData.AllowPaging = true;
pagedData.PageSize = PageSize;
pagedData.CurrentPageIndex = CurrentPageIndex;
base.DataSource = pagedData;
base.DataBind();
}
}
}
View 2 Replies