我这里带了参数,原因是这个函数会被带有不同条件参数的方法调用
int Count;
public void Newslistpage(string strwhere) { DataTable ds = new DataTable(); int _currentpageindex = 1; if (!string.IsNullOrEmpty(Request["Page"])) _currentpageindex = int.Parse(Request["Page"]);if (strwhere=="")
{ ds = WebHelp.DALHelper.GetmuchList("tb_News", "tb_NewsClass", " * ", "Newsid", "Nclassid", "Nclassid", AspNetPager1.PageSize, _currentpageindex, "Newsid desc", " subjectid=1 ", "*", out Count).Tables[0]; } else if (WebHelp.CRCommon.isNumber(Request.QueryString["nclassid"]) == false) { lmges.Visible = true; } else { ds = WebHelp.DALHelper.GetmuchList("tb_News", "tb_NewsClass", " * ", "Newsid", "Nclassid", "Nclassid", AspNetPager1.PageSize, _currentpageindex, "Newsid desc", " subjectid=1 and " + strwhere + " ", "*", out Count).Tables[0]; } AspNetPager1.RecordCount = Count; AspNetPager1.CustomInfoHTML = "共" + AspNetPager1.RecordCount.ToString() + "条,"; AspNetPager1.CustomInfoHTML += "" + AspNetPager1.PageCount.ToString() + "页,"; AspNetPager1.CustomInfoHTML += "第" + _currentpageindex + "页"; if (ds.Rows.Count > 0) { this.Rp_newslist.DataSource = ds; this.Rp_newslist.DataBind(); } else { lmges.Visible = true; } }