protected PagedDataSource pds() { string sql = ""; if (Request["key"] != null) { sql = " and title like '%" + Request["key"] + "%' "; tbKey.Text = Request["key"]; } if (Request["username"] != null && Request["username"] != "") { sql += " and username='******'"; tbusername.Text = Request["username"]; } if (Request["time1"] != null && Request["time1"] != "") { sql += " and addtime>='" + Request["time1"] + "'"; tbTime1.Text = Request["time1"]; } if (Request["time2"] != null && Request["time2"] != "") { sql += " and addtime<='" + Request["time2"] + "'"; tbTime2.Text = Request["time2"]; } if (Request["type"] != null && Request["type"] != "all") { sql += " and type=" + Request["type"] + ""; this.ddltype.SelectedValue = Request["type"]; } string sql3 = " order by addtime desc"; if (Request["paixu"] != null) { sql3 = " order by " + Request["paixu"] + " " + Request["paixu2"]; this.drPaixu.SelectedValue = Request["paixu"]; this.drPaixu2.SelectedValue = Request["paixu2"]; } // string sql2 = "select * from tFeedBack where 1=1 " + sql + sql3; string sql2 = string.Format("where 1=1 {0} {1}", sql, sql3); //Response.Write(sql); //Response.End(); PagedDataSource pds = new PagedDataSource(); pds.DataSource = FeedBackService.GetTable(sql2); pds.AllowPaging = true; //允许分页 pds.PageSize = 20; //分页数 pds.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]); //当前页CurrentPageIndex,通过获得传来的参数page来设置 return(pds); }