Datalist paginated write displays 10 pages each time, from the next page to the next 10 pages

Source: Internet
Author: User

<Table width = "100%" border = "0" cellspacing = "0" cellpadding = "0" style = "margin-bottom: 10px;
Margin-top: 6px; ">
<Tr>
<Td colspan = "2" align = "center" id = "td11" style = "height: 14px" ><%= pg %>
<Asp: HyperLink ID = "HyperLink4" runat = "server"> previous page </asp: HyperLink>
<Asp: HyperLink ID = "HyperLink5" runat = "server"> next page </asp: HyperLink>
<Asp: Label ID = "Label1" runat = "server"> </asp: Label> </td>
</Tr>
</Table>

Above is

// Assign values to relevant attributes of the PagedDataSource object
PagedDataSource objPds = new PagedDataSource ();
ObjPds. DataSource = ds. Tables ["property"]. DefaultView;
ObjPds. AllowPaging = true;
// Several items are displayed on one page
ObjPds. PageSize = 40;
// Current page
Int CurPage;
// Obtain the query parameters from the Page on the current Page
If (Request. QueryString ["Page"]! = Null)

CurPage = Convert. ToInt32 (Request. QueryString ["Page"]);
Else
CurPage = 1;
If (Request. QueryString ["_ Page"]! = Null)
{
_ Pg = Convert. ToInt32 (Request. QueryString ["_ Page"]);
}

ObjPds. CurrentPageIndex = CurPage-1;
This. Label1.Text = "Current page number:" + CurPage. ToString ();

// Assign the PagedDataSource object to the control
This. DataList1.DataSource = objPds;
This. DataList1.DataBind ();

// Jump directly
Int page = 1;

If (ds. Tables ["property"]. Rows. Count % objpps. PageSize = 0)
{
Page = ds. Tables ["property"]. Rows. Count/objtp.pagesize;
}
Else
{
Page = ds. Tables ["property"]. Rows. Count/objpps. PageSize + 1;
}
String ul = null;
Int j = 1 * (_ pgSize * (_ pg-1) + 1;
If (page <10)
{
_ PgSize = page;
}
Int spage;
Spage = _ pgSize * _ pg;
If (spage> page)
{
This. HyperLink5.Visible = false;
Spage = page;
}
Else
{
This. HyperLink5.NavigateUrl = Request. CurrentExecutionFilePath + "? Page = "+ (j + 10) +" & _ Page = "+ (_ pg + 1 );
}

For (int I = j; I <spage + 1; I ++)
{
Ul = Request. CurrentExecutionFilePath + "? Page = "+ I +" & _ Page = "+ _ pg ;;
If (I = CurPage)
{
Pg + = "<a href =" + ul + "> <big> <font color = red>" + I + "</font> </big> </a> ";
}
Else
{
Pg + = "<a href =" + ul + "> <big>" + I + "</big> </a> ";
}

}
If (_ pg = 1)
{
This. HyperLink4.Visible = false;
}
Else
{
This. HyperLink4.NavigateUrl = Request. CurrentExecutionFilePath + "? Page = "+ (J-1) +" & _ Page = "+ (_ pg-1 );
}

 

 

 

Bytes ----------------------------------------------------------------------------------------

Some public attributes of the PagedDataSource class:
AllowCustomPaging gets or sets the value indicating whether to enable custom paging.
AllowPaging gets or sets the value indicating whether to enable pagination.
Count to obtain the number of items to be used from the data source.
CurrentPageIndex gets or sets the index of the current page.
DataSource obtains or sets the data source.
Cececount gets the number of items in the data source.
FirstIndexInPage gets the first index on the page.
IsCustomPagingEnabled gets a value indicating whether to enable custom paging.
IsFirstPage gets a value indicating whether the current page is a homepage.
IsLastPage gets a value indicating whether the current page is the last page.
IsPagingEnabled gets a value indicating whether to enable paging.
IsReadOnly gets a value indicating whether the data source is read-only.
IsSynchronized gets a value indicating whether to synchronize access to the data source (thread safety ).
PageCount obtains the total number of pages required for all items in the data source.
PageSize gets or sets the number of items to be displayed on a single page.
VirtualCount gets or sets the actual number of items in the data source when custom pages are used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.