Front-end code:
& Nbsp;
<Asp: DropDownList ID = "ddlPageSize" runat = "server" AutoPostBack = "true" OnSelectedIndexChanged = "ddlPageSize_SelectedIndexChanged">
<Asp: ListItem Value = "10"> 10 </asp: ListItem>
<Asp: ListItem Value = "20"> 20 </asp: ListItem>
<Asp: ListItem Value = "30"> 30 </asp: ListItem>
<Asp: ListItem Value = "40"> 40 </asp: ListItem>
<Asp: ListItem Value = "50"> 50 </asp: ListItem>
</Asp: DropDownList>
& Nbsp; Entries & nbsp; Total & nbsp; <asp: Label ID = "lblRecordCount" runat = "server" Text = ""> </asp: label> & nbsp; message & nbsp;
Page/
Total & nbsp; <asp: Label ID = "lblPageCount" runat = "server" Text = ""> </asp: Label> & nbsp; Page & nbsp;
<Asp: Button ID = "btnFirst" runat = "server" Text = "first page" OnClick = "btnFirst_Click"/> & nbsp;
<Asp: Button ID = "btnPrev" runat = "server" Text = "Previous Page" OnClick = "btnPrev_Click"/> & nbsp;
<Asp: Button ID = "btnNext" runat = "server" Text = "next page" OnClick = "btnNext_Click"/> & nbsp;
<Asp: Button ID = "btnLast" runat = "server" Text = "last page" OnClick = "btnLast_Click"/> & nbsp;
Go to the <input type = "text" id = "textfield" size = "3" onkeyup = "javascript: checkIsInt ();"
Runat = "server"/>
Page
<Asp: Button ID = "btnGoPageIndex" class = "smallbutton" runat = "server" Text = "GO" Style = "border: 0;
Width: 20px; height: 15px; "OnClick =" btnGoPageIndex_Click "/> & nbsp;
<Input name = "chkall" type = "checkbox" id = "chkall" value = "select" onclick = "CheckAll (this. form)"/> <label
For = "chkAll"> select all </label> & nbsp;
<Asp: Button ID = "btnDel" runat = "server" OnClick = "btnDel_Click" Text = "batch Delete" OnClientClick = "return delIt ()"/>
</Div>
Background code:
# Region data binding and paging
// Display by PAGE
Public void contrlrepeater ()
{
DataSet ds = (DataSet) ViewState ["ds"]; // bound DataSet
If (ds. Tables [0]. Rows. Count> 0)
{
// Set and bind data by PAGE
PagedDataSource PPS = new PagedDataSource ();
Pds. DataSource = ds. Tables [0]. DefaultView;
PPS. AllowPaging = true; // run the page
PPS. PageSize = Convert. ToInt32 (this. ddlPageSize. SelectedValue); // you can specify the number of entries displayed on each page.
PPS. CurrentPageIndex = Convert. ToInt32 (this. lblPageIndex. Text)-1; // set the current page
Repeater1.DataSource = PPS;
This. lblPageCount. Text = PPS. PageCount. ToString ();
This. lblPageIndex. Text = (PPS. CurrentPageIndex + 1). ToString ();
This. lblRecordCount. Text = ds. Tables [0]. Rows. Count. ToString ();
This. btnFirst. Enabled = true;
This. btnPrev. Enabled = true;
This. btnNext. Enabled = true;
This. btnLast. Enabled = true;
If (PPS. CurrentPageIndex <1)
{
This. btnFirst. Enabled = false;
This. btnPrev. Enabled = false;
}
If (maid. CurrentPageIndex = maid. PageCount-1)
{
This. btnNext. Enabled = false;
This. btnLast. Enabled = false;
}
If (PPS. PageCount = 1)
{
This. btnGoPageIndex. Enabled = false;
}
Repeater1.DataBind ();
}
Else
{
This. lblPageCount. Text = "0 ";
This. lblPageIndex. Text = "0 ";
This. lblRecordCount. Text = "0 ";
This. ddlPageSize. Enabled = false;
This. btnFirst. Enabled = false;
This. btnPrev. Enabled = false;
This. btnNext. Enabled = false;
This. btnLast. Enabled = false;
This. btnGoPageIndex. Enabled = false;
This. btnDel. Enabled = false;
Repeater1.DataSource = null;
Repeater1.DataBind ();
}
}
// Change the number of entries displayed on each page
Protected void ddlPageSize_SelectedIndexChanged (object sender, EventArgs e)
{
This. lblPageIndex. Text = "1 ";
This. contrlrepeater ();
}
/// <Summary>
// Home Page
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void btnFirst_Click (object sender, EventArgs e)
{
This. lblPageIndex. Text = "1 ";
This. contrlrepeater ();
}
/// <Summary>
/// Previous Page
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void btnPrev_Click (object sender, EventArgs e)
{
This. lblPageIndex. Text = Convert. ToString (Convert. ToInt32 (this. lblPageIndex. Text)-1 );
This. contrlrepeater ();
}
/// <Summary>
/// Next page
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void btnNext_Click (object sender, EventArgs e)
{
This. lblPageIndex. Text = Convert. ToString (Convert. ToInt32 (this. lblPageIndex. Text) + 1 );
This. contrlrepeater ();
}
/// <Summary>
/// End page
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void btnLast_Click (object sender, EventArgs e)
{
This. lblPageIndex. Text = this. lblPageCount. Text;
This. contrlrepeater ();
}
/// <Summary>
/// Jump
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void btnGoPageIndex_Click (object sender, EventArgs e)
{
If (this. textfield. Value. Trim (). ToString ()! = "")
{
This. lblPageIndex. Text = this. textfield. Value;
This. contrlrepeater ();
}
}
# Endregion