//初始列表 private void BindGrid() { DataTable lists = bll.GetItemList(userId, today); List.DataSource = lists; List.DataBind(); }
//初始列表 private void BindItemGrid() { DateTime now = Convert.ToDateTime(curDate).Date; DateTime beginDate = DateTime.Now.Date; DateTime endDate = DateTime.Now.Date; DateTime cachedate = DateTime.Now.Date; switch (showType) { case "a": beginDate = DateHelper.GetSqlMinDate(); endDate = DateHelper.GetSqlMaxDate(); break; case "d": beginDate = DateHelper.GetCurDate(now); endDate = DateHelper.GetCurDate(now); break; case "w": beginDate = DateHelper.GetWeekFirst(now); endDate = DateHelper.GetWeekLast(now); break; case "m": beginDate = DateHelper.GetMonthFirst(now); endDate = DateHelper.GetMonthLast(now); break; case "y": beginDate = DateHelper.GetYearFirst(now); endDate = DateHelper.GetYearLast(now); break; } DataTable newlists = new DataTable(); lists = bll.GetItemList(userId, beginDate, endDate); if (lists.Rows.Count > 0) { DataRow[] rows = lists.Select(GetRowFilter(), string.Format("{0} {1}", sort, by)); if (rows.Length > 0) { newlists = rows.CopyToDataTable(); } //lists.DefaultView.RowFilter = GetRowFilter(); //lists.DefaultView.Sort = string.Format("{0} {1}", sort, by); } this.ItemGrid.DataSource = newlists; this.ItemGrid.DataBind(); //更新总价 UpdateTotal(newlists); }