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 ();
Break
}
Bindgrid ();
}
void Mydatagrid_page (Object sender, DataGridPageChangedEventArgs e)
{
How to handle numbers
Bindgrid ();
}
void Bindgrid ()
{
Bind DataView to the DataGrid
Mydatagrid.datasource = CreateDataSource ();
Mydatagrid.databind ();
Showstats ();
}
void Showstats ()
{
Display page Information
Lblcurrentindex.text = "Current page is:" +
((int) mydatagrid.currentpageindex+1);
Lblpagecount.text = "Total number of pages is:" + mydatagrid.pagecount;
}
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.