TopicList.aspx.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. using CB.Common;
  8. using CB.Data;
  9. using CB.Entity;
  10. using CB.Framework;
  11. namespace CB.Admin.Plugins.Basic
  12. {
  13. public partial class TopicList : AdminPage
  14. {
  15. IList<TopicClassInfo> topicTypes = TopicClassService.ToList();
  16. protected void Page_Load(object sender, EventArgs e)
  17. {
  18. if (!Page.IsPostBack)
  19. {
  20. InitData();
  21. }
  22. }
  23. protected override void InitData()
  24. {
  25. BindRepeaterList();
  26. base.InitData();
  27. }
  28. protected override void BindRepeaterList()
  29. {
  30. int recordCount;
  31. var list = CB.Data.TopicService.ToPaging(new Entity.TopicInfo()
  32. {
  33. Title = txtTitle.Text.Trim()
  34. }, AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, out recordCount);
  35. repeaterList.DataSource = list;
  36. repeaterList.DataBind();
  37. AspNetPager1.RecordCount = recordCount;
  38. }
  39. //查询
  40. protected void btnSearch_Click(object sender, EventArgs e)
  41. {
  42. AspNetPager1.CurrentPageIndex = 1;
  43. BindRepeaterList();
  44. }
  45. protected string GettopicTypesName(string id)
  46. {
  47. string name = "";
  48. var topic = topicTypes.FirstOrDefault(x => x.Cid == TypeConverter.StrToInt(id));
  49. if (topic != null) { name = topic.Name; }
  50. return name;
  51. }
  52. protected void repeaterList_ItemCommand(object source, RepeaterCommandEventArgs e)
  53. {
  54. if ("dndel" == e.CommandName)
  55. {
  56. CB.Data.TopicService.Delete(TypeConverter.ObjectToInt(e.CommandArgument));
  57. Logs("删除 ", string.Format("删除 [TID={0}]", e.CommandArgument));
  58. }
  59. BindRepeaterList();
  60. }
  61. //翻页
  62. protected void AspNetPager1_PageChanged(object sender, EventArgs e)
  63. {
  64. BindRepeaterList();
  65. }
  66. }
  67. }