62,244
社区成员




<webdiyer:aspnetpager id="AspNetPager1" runat="server" firstpagetext="首页" lastpagetext="尾页"
nextpagetext="后页" onpagechanging="AspNetPager1_PageChanging" prevpagetext="前页"
ShowPageIndexBox="Always" SubmitButtonText="Go" TextAfterPageIndexBox="页"
TextBeforePageIndexBox="转到" CustomInfoHTML="第%CurrentPageIndex%页,共%PageCount%页,每页%PageSize%条" CustomInfoSectionWidth="30%" PageIndexBoxType="DropDownList" ShowCustomInfoSection="Left"> </webdiyer:aspnetpager>
public DataSet ds;
public int aid = Convert.ToInt16(SqlZr.DelSQLStr(HttpContext.Current.Request.QueryString["cid"].ToString()));
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable ds1 = product.getproductsbyclass2id(aid).Tables[0];
AspNetPager1.AlwaysShow = true;
AspNetPager1.PageSize = 15;
AspNetPager1.RecordCount = ds1.Rows.Count;
bind();
show();
}
}
private void bind()
{
using (SqlDataReader sdr = product.GetSingleClass(aid))
if (sdr.Read())
{
pname.Text = sdr["P_name"].ToString();
pinfo.Text = sdr["P_ename"].ToString();
}
}
private void show()
{
SqlConnection con = new SqlConnection(SqlHelper.CONNSTR);
con.Open();
SqlDataAdapter dr = new SqlDataAdapter("select * from products where P_class1="+aid+" order by P_time desc", con);
ds = new DataSet();
dr.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "Employees");
DataList1.DataSource = ds.Tables["Employees"];
DataList1.DataBind();
con.Close();
}
protected void AspNetPager1_PageChanging(object src, PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
bind();
}
protected void AspNetPager1_PageChanging(object src, PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
bind();
}
protected void AspNetPager1_PageChanged(object src, PageChangingEventArgs e)
{
bind();
}
protected void AspNetPager1_PageChanged(object src, PageChangingEventArgs e)
{
bind();
}
protected void AspNetPager1_PageChanged(object src, PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
bind();
}