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

    private void Bind()
    {

        if (Request.QueryString["QuestionNo"] != null)
        {
            string QuestionNo = Request.QueryString["QuestionNo"].ToString();
  
            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\" style=\"color:Red;font-weight:bold;\">数据为空</td></tr>";
            }

        }

    }

上一篇:小工具 - 批量删除Maven下载失败的文件夹


下一篇:【BBED】使用bbed解决 the amount of space used is not equal to block size