1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- public partial class _Default : System.Web.UI.Page
- {
- AccessHelper helper = new AccessHelper();
- string cond = "caid=6";
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- helper.CreateCommand("select count(*) from news where "+cond);
- anp.RecordCount = int.Parse(helper.ExecuteScalar());
- bindrep();
- }
- }
- /// <summary>
- /// 页面翻页触发事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void anp_PageChanged(object sender, EventArgs e)
- {
- bindrep();
- }
- /// <summary>
- /// 绑定分页
- /// </summary>
- private void bindrep()
- {
- int pagesize = anp.PageSize;
- int pageindex = anp.CurrentPageIndex;
- gv.DataSource = helper.FengYe("(news n inner join newsca ca on n.caid=ca.id)", "*", "createdate", "desc", cond, pagesize, pageindex);
- gv.DataBind();
- }
- }
|