using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Bind();
}
private void Bind()
{
//将总条数放到分页控件中
DataTable dt1 = null;
dt1 = DataCtrl.selecttable("select count(classname) from mess_class","tabnl");
// this.pager.RecordCount=System.Convert.ToInt32(ds.Tables[0].Rows[0][0]);
this.AspNetPager1.RecordCount = System.Convert.ToInt32(dt1.Rows[0][0]);
Bind1();
}
private void Bind1()
{
SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=xuedao;database=zhaoxuedaonet");
SqlCommand comm = new SqlCommand("select classname from mess_class",conn);
conn.Open();
comm.ExecuteNonQuery();
DataSet ds = new DataSet();
SqlDataAdapter dapter = new SqlDataAdapter(comm);
dapter.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex-1),AspNetPager1.PageSize,"table");
this.DataList1.DataSource = ds.Tables["table"].DefaultView;
this.DataList1.DataBind();
//AspNetPager1.CustomInfoText = "记录总数:<font color=\"blue\"><b>" + AspNetPager1.RecordCount.ToString() + "</b></font>";
//AspNetPager1.CustomInfoText = "总页数:<font color=\"blue\"><b>" + AspNetPager1.PageCount.ToString() + "</b></font>";
//AspNetPager1.CustomInfoText = " 当前页:<font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>";
//myda.Fill(ds, pager.PageSize * (pager.CurrentPageIndex - 1), pager.PageSize, "article");
//this.dgList.DataSource = ds.Tables["article"];
//this.dgList.DataBind();
////动态设置用户自定义文本内容
//pager.CustomInfoText = "记录总数:<font color=\"blue\"><b>" + pager.RecordCount.ToString() + "</b></font>";
//pager.CustomInfoText += " 总页数:<font color=\"blue\"><b>" + pager.PageCount.ToString() + "</b></font>";
//pager.CustomInfoText += " 当前页:<font color=\"red\"><b>" + pager.CurrentPageIndex.ToString() + "</b></font>";
}
protected void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
Bind1();
//pager.CurrentPageIndex = e.NewPageIndex;
//BindData();
//System.Text.StringBuilder sb = new StringBuilder("<script Language=\"Javascript\"><!--\n");
//sb.Append("var el=document.all;");
//sb.Append(this.dgList.ClientID);
//sb.Append(".scrollIntoView(true);");
//sb.Append("<");
//sb.Append("/");
//sb.Append("script>");
//if (!Page.IsStartupScriptRegistered("scrollScript"))
// Page.RegisterStartupScript("scrollScript", sb.ToString());
}
}