Default.aspx.cs 931 B

123456789101112131415161718192021222324252627282930313233
  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. protected void anp_PageChanged(object sender, EventArgs e)
  21. {
  22. bindrep();
  23. }
  24. private void bindrep()
  25. {
  26. int pagesize = anp.PageSize;
  27. int pageindex = anp.CurrentPageIndex;
  28. gv.DataSource = helper.FengYe("(news n inner join newsca ca on n.caid=ca.id)", "*", "createdate", "desc", cond, pagesize, pageindex);
  29. gv.DataBind();
  30. }
  31. }