using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class control_news : System.Web.UI.UserControl { public string newscontent = string.Empty;//内容 public DataSet dsjsq = Fun.Funjsqid(); public int pagesite = 10;//一页显示多少个 public int page = 1; public int start = 0;//从第几条开始读取 public int classid = 0; protected void Page_Load(object sender, EventArgs e) { Pager1.PageSize = pagesite; if (Request.QueryString["page"] != null) { page = Convert.ToInt32(Request.QueryString["page"].ToString()); } string classstr = ""; if (Request.QueryString["classid"] != null && Request.QueryString["classid"] != "" && Request.QueryString["classid"] != "0") { classid = Convert.ToInt32(Request.QueryString["classid"].ToString()); classstr = "&classid=" + classid; } Pager1.PageSize = pagesite; start = (page - 1) * pagesite; string web=string.Empty; web = Fun.Funnewscountxml() + "?jsqid=" + dsjsq.Tables[0].Rows[0]["jsqid"].ToString() + "" + classstr; try { DataSet dss = new DataSet(); dss.ReadXml(web); if (dss.Tables.Count > 0) { Pager1.RecordCount = Convert.ToInt32(dss.Tables[0].Rows[0]["count"].ToString()); } } catch { } string website = string.Empty; website = Fun.Funnewspartxml() + "?jsqid=" + dsjsq.Tables[0].Rows[0]["jsqid"].ToString() + "&num=" + dsjsq.Tables[0].Rows[0]["newwords"].ToString() + "" + classstr + "&top=" + pagesite + "&start=" + start + ""; DataSet ds = new DataSet(); try { ds.ReadXml(website); if (ds.Tables.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string id = ds.Tables[0].Rows[i]["id"].ToString(); string name = Server.UrlDecode(ds.Tables[0].Rows[i]["name"].ToString()); string description = Server.UrlDecode(ds.Tables[0].Rows[i]["description"].ToString()); string updatetime = ds.Tables[0].Rows[i]["updatetime"].ToString(); string clid = ds.Tables[0].Rows[i]["classid"].ToString(); newscontent += "
  • " + name + "" + updatetime + "
  • "; newscontent += "
  • " + description + "...
  • "; } } } catch { } } }