protected void Page_Load(object sender, EventArgs e) { if (!Int32.TryParse(Request.QueryString["page"], out pageNum)) { pageNum = 1; } pageSize = 10; pageCount = getPageCount(pageSize); if (!IsPostBack) { if (pageNum >= pageCount) { pageNum = pageCount; } ArticlesBind(pageNum, pageSize); effect(); } using (var db = new CstwebEntities()) { var lo = (from it in db.games orderby it.addtime descending select it).ToList(); List <games1> lo2 = new List <games1>(); foreach (games ga in lo) { games1 ga1 = new games1(); ga1.id = ga.id; ga1.body = ga.body; ga1.gamename = ga.gamename; ga1.status = ga.status; if (ga.status == 1) { ga1.gamestatus = @"<div class='comp-status comp-noting'>比赛尚未开始</div>"; } else if (ga.status == 2) { ga1.gamestatus = @"<div class='comp-status comp-ing'>比赛进行中</div>"; } lo2.Add(ga1); } RptGame.DataSource = lo2; RptGame.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int currentPage = 1; int pageSize = 10; Session["pagenum"] = 1; ArticlesBind(currentPage, pageSize); } using (var db = new CstwebEntities()) { var lo = (from it in db.games select it).ToList(); List<games1> lo2 = new List<games1>(); foreach (games ga in lo) { games1 ga1 = new games1(); ga1.id = ga.id; ga1.body = ga.body; ga1.gamename = ga.gamename; ga1.status = ga.status; if (ga.status == 1) { ga1.gamestatus = @"<div class='comp-status comp-noting'>比赛尚未开始</div>"; } else if (ga.status == 2) { ga1.gamestatus = @"<div class='comp-status comp-ing'>比赛进行中</div>"; } lo2.Add(ga1); } RptGame.DataSource = lo2; RptGame.DataBind(); } effect(); }