Intimate contact asp.net (14)

Source: Internet
Author: User
Personalized Paging (2)
In the last section, we did not see the overall structure, this section, I put the code all posted out, we have a good look.
<%@ Page language= "C #"%>
<%@ Import namespace= "System.Data"%>
<%@ Import namespace= "System.Data.SQL"%>
<script language= "C #" runat= "Server" >
void Page_Load (Object sender, EventArgs e)
{
Decide whether to hide Pagerstyle-mode
if (chk1. Checked)
{
Mydatagrid.pagerstyle.visible=true;
}
Else
{
Mydatagrid.pagerstyle.visible=false;
}
Bindgrid ();
}
ICollection CreateDataSource ()
{
/*
Read the database information and get the DataView
*/
SqlConnection myconnection = new
SqlConnection ("SERVER=LOCALHOST;UID=SA;PWD=123456;DATABASE=ASPCN");
Sqldatasetcommand Mydatasetcommand = new Sqldatasetcommand ("SELECT * FROM
Admin_enter ORDER BY enter_time Desc ", MyConnection);
DataSet ds= new DataSet ();
Mydatasetcommand.filldataset (ds, "Admin_enter");
Return DS. tables["Admin_enter"]. DefaultView;
}
void Pagerbuttonclick (Object sender, EventArgs e)
{
Get the LinkButton parameter value
String arg = ((LinkButton) sender). CommandArgument;
Switch (ARG)
{
Case ("Next"):
if (Mydatagrid.currentpageindex < (mydatagrid.pagecount-1))
Mydatagrid.currentpageindex + +;
Break
Case ("prev"):
if (Mydatagrid.currentpageindex > 0)
Mydatagrid.currentpageindex--;
Break
Case ("Last"):
Mydatagrid.currentpageindex = (mydatagrid.pagecount-1);
Break
Default
Value of this page
Mydatagrid.currentpageindex = arg. ToInt32 ();

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.