I need a load more button to control the repeater shown content.
Here is my steps in the back end after load more button was clicked:
Suppose these steps can give me the expected output?
//Declaration
public static int max = 0;
public static int totalShow = 0;
//SetupControl()
if(!IsPostBack){
rptItems.ClassName = "Blog";
rptItems.Path = "/Shared/%"
rptItems.DataBind();
max = rptItems.Items.Count();
}
//This part is put under a new function
totalShow += 1;
rptItems.SelectTopN = totalShow;
rptItems.DataBind();
lbnLoadMore.Visible = rptItems.Items.Count() < max;
Besides, I'm confusing about the functions as shown below:
Both are from the class CMSRepeater
, what's the different? Which one should I use in order to set the limits?
Using static
members is definitely not a good approach. Their values would be shared by all users of the application. There are better ways of storing user-specific data:
Regarding TopN
and SelectTopN
, they do the same thing. It's probably because of backward compatibility.
From the algorithmical point of view, there's no need to bind data multiple times nor to make more than one round-trip to the database. You just need to initialize the datasource/repeater with correct values.
I'd recommend you reading the following articles to get some inspiration: