protected PagedDataSource pds() { string sql = ""; if (Request["type"] != null) { if (Request["type"] != "all") { sql += " and type=" + int.Parse(Request["type"]); } this.ddlType.SelectedValue = Request["type"]; } if (Request["key"] != null) { sql += "and title like '%" + Request["key"] + "%'"; this.tbKey.Text = Request["key"]; } PagedDataSource pds = new PagedDataSource(); pds.DataSource = LinkService.GetTable(string.Format("where 1=1 {0} order by sort desc", sql)); pds.AllowPaging = true; //允许分页 pds.PageSize = 20; //分页数 pds.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]); //当前页CurrentPageIndex,通过获得传来的参数page来设置 return(pds); }