zl程序教程

您现在的位置是:首页 >  后端

当前栏目

linq查询集合并分页展示数据

集合数据 查询 分页 展示 LinQ
2023-09-27 14:28:17 时间
string BeginDate = DateTime.Now.AddMonths(-2).ToShortDateString(); string EndDate = DateTime.Now.AddDays(1).ToShortDateString(); string strWhere = "SELECT * FROM (SELECT id,QuestionNo,ServiceCode,现场服务单 as 类型,Result,CreateDate FROM A_Service union all SELECT id,QuestionNo,ServiceCode,未解决单 as 类型,Result,CreateDate FROM A_NotSolve) as a where 1=1"; strWhere += "and QuestionNo =" + QuestionNo + " and QuestionNo and CreateDate =" + BeginDate + " and CreateDate " + EndDate + ""; if (ViewState["strWhere"] != null) strWhere += ViewState["strWhere"].ToString(); DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strWhere); if (ds.Tables[0].Rows.Count 0) var query = (from t in ds.Tables[0].AsEnumerable() // where t.Field string ("QuestionNo") == QuestionNo select t).Skip((this.Pager.CurrentPageIndex - 1) * this.Pager.PageSize).Take(this.Pager.PageSize); DataTable boundTable = query.CopyToDataTable DataRow RepeaterCommentList.DataSource = boundTable; RepeaterCommentList.DataBind(); Pager.RecordCount = ds.Tables[0].Rows.Count; else Msg = " tr td colspan=\"6\" align=\"center\" valign=\"top\" bgcolor=\"#ffffff\" "color:Red;font-weight:bold;\" 数据为空 /td /tr }