 |
|
|
 |
|
 |
Hi, I'd like to have a pager at the top and bottom of my .NET repeater. What's the simpliest way to achieve this without duplicating tons of code?
Thanks!
|
|
|
|
 |
|
 |
Hello, I made some updates time ago that included top and bottom pagers availability. Just wait, I'll upload it
|
|
|
|
 |
|
 |
Hey, I'd like to have a dropdown list that lets the user filter how many records are shown per page. I'll obviously need to set the PageSize property on the SelectedIndexChanged event of the dropdown, but what else needs to happen? Do I need to rebind the pager? Do I need to set the PageIndex to something specific? What if the user is on page 3 for example, and they change the PageSize. What should happen?
Thanks!
Jason
|
|
|
|
 |
|
 |
Sure, you have to binds data when PageSize being changed to create Repeater content according to new page size.
|
|
|
|
 |
|
 |
Hie I am trying to use your component, but my am doing my project in vb.net. Is it possible to still use your component. I think its a great component from what i have read.
|
|
|
|
 |
|
 |
Hi again. I've been trying out the pager a bit more, and I've spotted a problem that I'd really appreciate your help with.
Basically I'm using a repeater and the pager to show search results on a page. I'm allowing six results per page.
If I try a search that produces three results, no pager is shown (as expected). If I then change the search phrase so that eight results would be returned, the first six are shown, but the pager still doesn't appear.
Likewise, if I try the 'eight results' search first, I get the pager. If I then change it to the 'three results' search, it shows those three, but also the pager. If I click to go to Page 2 the page refreshes, showing the same three results and this time the pager disappears.
The only way to successfully get the pager to appear as it should is to navigate away and back to the search page again. So it must be a PostBack issue, but I can't think of a way around it. Am I missing something obvious?
|
|
|
|
 |
|
 |
Petr I have the same problem. Have you find a solution to fix this issue?
I send a sample code
<script runat="server">
void BindData()
{
ddlFecha.DataSource = NoticiasBLL.GetFecha();
ddlFecha.DataValueField = "Fecha";
ddlFecha.DataTextField = "Fecha";
ddlFecha.DataBind();
ddlFecha.Items.Insert(0, new ListItem("", "0-0"));
repItemsPager.DataSource = ods.Select();
repItemsPager.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
btnBuscar.Attributes.Add("onmouseover", "this.src='img/btnhover.jpg'");
btnBuscar.Attributes.Add("onmouseout", "this.src='img/btn.jpg'");
if (!Page.IsPostBack)
{
BindData();
}
if (Page.IsPostBack)
{
repItemsPager.DataSource = ods.Select();
repItemsPager.DataBind();
}
}
protected void PageChanged(object sender, RepeaterPageChangedEventArgs e)
{
repItemsPager.PageIndex = e.NewPageIndex;
repItemsPager.DataSource = ods.Select();
repItemsPager.DataBind();
}
protected void btnBuscar_Click(object sender, ImageClickEventArgs e)
{
ods.SelectParameters["Param"].DefaultValue = tbBuscar.Text;
string[] valor = ddlFecha.SelectedValue.Split(new char[] { '-' });
ods.SelectParameters["ano"].DefaultValue = valor[1].ToString();
ods.SelectParameters["mes"].DefaultValue = valor[0].ToString();
}
</script>
<asp:Content ID="contentIzquierda" ContentPlaceHolderID="cphIzquerda" runat="server">
<ucArzion:Empresas ID="empresas" runat="server" />
<asp:Content ID="Content1" ContentPlaceHolderID="centro" runat="Server">
Listado de noticias
Buscador:
<asp:TextBox ID="tbBuscar" runat="server" CssClass="textbox" />
<asp:DropDownList ID="ddlFecha" runat="server" CssClass="textbox" />
<asp:ImageButton ID="btnBuscar" runat="server" ImageUrl="img/btn.jpg" OnClick="btnBuscar_Click">
<asp:Repeater ID="rpt" runat="server" >
<HeaderTemplate>
</HeaderTemplate>
<%# (new Thumb(Eval("Foto").ToString(),60,60,true,Eval("Foto").ToString())).GenerateThumbnail() %>
<%# Eval("Titulo") %>
<%# Eval("Fecha", "{0:dd/MM/yy}") %>
<%# Utiles.stripHTML(Eval("DescripcionBreve").ToString()) %>
+ Ver más
<ctl:RepeaterPager ID="repItemsPager" runat="server" RepeaterID="rpt" PageSize="5"
önPageIndexChanged="PageChanged" PagingType="Classic" PagersType="OnlyNumeric" TextBeforeNumericPagers="Página »" MaxNumericPagers="10" Visible="true">
<asp:LinkButton ID="lbNext" runat="server" Text="sig »" CommandName="Page">
<asp:LinkButton ID="lbPrevious" runat="server" Text="« ant" CommandName="Page">
<asp:LinkButton ID="lbNumericPager" runat="server" Text="<%# Container.Value %>"
CommandName="Page">
<SelectedNumericPagerTemplate>
<%# Container.Value %>
</SelectedNumericPagerTemplate>
<asp:LinkButton ID="lbEmptyPager" runat="server" Text="..." CommandName="Page">
<asp:ObjectDataSource ID="ods" runat="server" SelectMethod="GetAll" TypeName="Arzion.Cms.NoticiasBLL">
<SelectParameters>
<asp:Parameter Name="Param" Type="string" ConvertEmptyStringToNull="true" DefaultValue="" />
<asp:Parameter Name="ano" Type="Int32" DefaultValue="0" />
<asp:Parameter Name="mes" Type="Int32" DefaultValue="0" />
</SelectParameters>
|
|
|
|
 |
|
 |
Yes, this was solved, but the solution was posted in a reply to a different thread (below this one):
http://www.codeproject.com/useritems/Paging_a_Repeater.asp?select=2200844&df=100&forumid=366869#xx2200844xx
Cheers,
Steve
|
|
|
|
 |
|
 |
Exactly what I was looking for. Thanks for making it available.
A couple of things, though. I can't work out what the Virtual Paging Type is. Are you able to explain this a bit further?
Also what does the EmptySpaceSize value do?
Thanks again for your hard work.
Cheers,
Steve
|
|
|
|
 |
|
 |
Hi Steve,
thats great feeling when one finds it handy . I'll try shortly answer your questions.
1) Virtul PagingType: from time to time you need to work with great data source that is extremely unsuitable to load all at time when binding data to component, you can provide only data from source corresponding to the selected page. Then you can set this data to the Pager and besides, you're obligged to set overall datasource size (VirtualItemsCount attribute).
2) EmptySpaceSize: you know, there are sometimes so many items to display, so the component generates big line of page links. This attribute defines minimal difference between first/last page and current page links group left/right border. On example: 1 ... 5 6 7 8 ... 20. That three dots represents what I call "space size", in this example EmptySpaceSize attribute can have possible values 1, 2, 3 and 4.
Is it understood? Its always best to play around with that
Let me know if having some other questions...
|
|
|
|
 |
|
 |
in OnDataBinding event,change these lines:
this.CreatePagers(((ICollection)DataSource).Count, this.PageSize, PagersType);
SetDataSourceSize(((ICollection)DataSource).Count);
to:
SetDataSourceSize(((ICollection)DataSource).Count);
this.CreatePagers(((ICollection)DataSource).Count, this.PageSize, PagersType);
|
|
|
|
 |
|
 |
That's great, thanks! That worked a treat.
Bit confusing, though. This is actually in reply to my *other* message, about refreshing the pager, and involves changing the original source code of the Repeater Pager: App_Code/RepeaterPager.cs (lines 538-547)
Thanks again for your help.
Cheers,
Steve
|
|
|
|
 |
|
 |
Hi
I tried the following code (i.e. returning DataTable as ICollection) but it doesn't work. There are 5 records in total, but I set the PageSize=3 for RepeaterPager control. The resulting table shows 5 records altogether without paging. Please can you help?
if (!IsPostBack)
{
rptNewsList.DataSource = GetLists();
rptNewsList.DataBind();
}
private ICollection GetLists()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSSQL"].ToString());
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT NewsId, Title, Abstract, ImageFile, DateUploaded FROM News WHERE CountryId=" + strCountryId + " OR CountryId=0 AND IsPublished='Y' ORDER BY DateUploaded DESC", conn);
DataSet ds = new DataSet();
da.Fill(ds);
return ds.Tables[0].DefaultView;
conn.Close();
}
Eva
|
|
|
|
 |
|
 |
Hi Eva,
I cant see from your code what type is that rptNewsList, looks like Repeater, or am I mistaken? Dont forget to set dataSource to Pager and not to Repeater itself. In addition, I'd appreciate declarative code defining Repeater and the Pager, could you send it to me? Thanks.
Nice d@y
|
|
|
|
 |
|
 |
hi!,
i have used your pagination control its really great control. But i am facing a problem with it. The page where i am using it shows initially all products of different categories in the repeater control. Each product displays with few details in which product name, author and Category are main. i have made "Category" as hyperlink. By clicking on the Category, page goes to postback and on the post back i am rebinding the control with new data according to the category which user has clicked.
Problem i am facing here, for the very first time pagination control works perfect and on clicking different page numbers it pulls records and shows properly in the repeater. But when i click on the category after post back it shows new records in the repeater control according to the clicked category but doesn't rebuild the pagination control according to these new records. And when i click on any page number it rebuilds the records according to the desired results.
I am badly stucked with this issue.. kindly help me out.. why do it is doing this problem. I am using Master Pages as well .. but i dont think that master pages can make this sort of trouble indeed.
Waiting for your earliest reply.
Regards
|
|
|
|
 |
|
 |
Hi fayalif,
in advance, thanks for using it. Your issue is not as straight as it seems. There are many places where the problem can come from. Beginning viewState set to false of some control, ending some postback conditions when loading data. Dont forget to set dataSource to Pager control, not to Repeater itself! So far, I think that best solution would be sending me some logical and simple extract of your code so I'm able to review it it, could you do that?
Reg@rds
|
|
|
|
 |
|
 |
Hi
Please tell me how can I connect DataSet as DataSource for pager control that you wrote....or how can I convert DataSet to ICollection
Thanks and waiting for your reply
Baber
Winners Never Quit And Quitters Never Win
|
|
|
|
 |
|
 |
Hi, first of all I'd like to thank you for choosing my component. Hope you'd have a fun with that.
To your question...DataSet itself cannot be used as a datasource (as you recognized). You must select certain DataTable from the DataSet and then call its "GetList()" method, that returns DataTable IList representation. And IList implements ICollection so you're having what's pager consumes as a datasource.
I hope I solved your problem. Have a nice day.
|
|
|
|
 |
|
 |
Hello Koutny.Paging Repeater is very good but I cant open it.I only use.
Please help me.
Thanks so much
|
|
|
|
 |
|
 |
Hi. I'm pleased you like my pagination mechanism. Reason may be, that you aren't running this website "http://repeaterpager.net.local", see .webinfo file in root of archive and change the setting according to your environment.
|
|
|
|
 |