Default.aspx.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. public partial class _Default : System.Web.UI.Page
  8. {
  9. AccessHelper helper = new AccessHelper();
  10. string cond = "caid=6";
  11. protected void Page_Load(object sender, EventArgs e)
  12. {
  13. if (!IsPostBack)
  14. {
  15. helper.CreateCommand("select count(*) from news where "+cond);
  16. anp.RecordCount = int.Parse(helper.ExecuteScalar());
  17. bindrep();
  18. }
  19. }
  20. /// <summary>
  21. /// 页面翻页触发事件
  22. /// </summary>
  23. /// <param name="sender"></param>
  24. /// <param name="e"></param>
  25. protected void anp_PageChanged(object sender, EventArgs e)
  26. {
  27. bindrep();
  28. }
  29. /// <summary>
  30. /// 绑定分页
  31. /// </summary>
  32. private void bindrep()
  33. {
  34. int pagesize = anp.PageSize;
  35. int pageindex = anp.CurrentPageIndex;
  36. gv.DataSource = helper.FengYe("(news n inner join newsca ca on n.caid=ca.id)", "*", "createdate", "desc", cond, pagesize, pageindex);
  37. gv.DataBind();
  38. }
  39. }