protected void Page_Load(object sender, EventArgs e) { if (Request["Id"] == null) { this.Page.Response.StatusCode = 404; this.Page.Response.End(); return; } DBContainer db = new DBContainer(); int id = int.Parse(Request["Id"]); List<dtType> typeList = db.dtType.ToList(); nav_Repeater.DataSource = typeList; nav_Repeater.DataBind(); dtInfo info =(from i in db.dtInfo where i.Id==id select i).FirstOrDefault(); if (info.BIsMode==true) { this.Page.Response.StatusCode = 404; this.Page.Response.End(); return; } typeName = info.dtType.CTypeName; typeId = info.dtType.Id; title = info.CTitle; time = info.DTPubDate.ToString("yyyy-MM-dd HH:mm"); content = info.CContent; }
protected void Page_Load(object sender, EventArgs e) { if (Request["Id"] == null) { this.Page.Response.StatusCode = 404; this.Page.Response.End(); return; } if (Request["PageNum"] != null) { PageNum = int.Parse(Request["PageNum"]); } DBContainer db = new DBContainer(); dtType type = null; int id = int.Parse(Request["Id"]); typeId = id; List<dtType> typeList = db.dtType.ToList(); nav_Repeater.DataSource = typeList; nav_Repeater.DataBind(); foreach (dtType item in typeList) { if (item.Id == id) { typeName = item.CTypeName; type = item; break; } } if (type == null) { this.Page.Response.StatusCode = 404; this.Page.Response.End(); return; } int startNum = (PageNum - 1) * ListSize; List<dtInfo> list = (from info in db.dtInfo where info.dtType.Id == id && info.BIsMode == false orderby info.Id descending select info).Skip(startNum).Take(ListSize).ToList(); foreach (var item in list) { if (item.CTitle.Length > TitleLength) { item.CTitle = item.CTitle.Substring(0, TitleLength - 1) + "…"; } } dtInfoRepeater.DataSource = list; dtInfoRepeater.DataBind(); count = (from info in db.dtInfo where info.dtType.Id == id && info.BIsMode == false select info).Count(); countPage = Math.Ceiling((double)count / ListSize); }
protected void Page_Load(object sender, EventArgs e) { DBContainer db = new DBContainer(); List<dtType> typeList = db.dtType.ToList(); nav_Repeater.DataSource = typeList; nav_Repeater.DataBind(); List<dtInfo> picInfoList = db.dtInfo.Where(i => i.BIsPic == true).Where(i => i.BIsMode == false).OrderByDescending(i=>i.Id).Take(5).ToList(); if (picInfoList.Count==0||picInfoList==null) { picInfoList=new List<dtInfo>(); dtInfo info =new dtInfo(){CTitle="暂无内容",CPicUrl="index_files/not_find_pic.png",BIsPic=false,Id=-1}; picInfoList.Add(info); } infoPicRepeater.DataSource = picInfoList; infoPicRepeater.DataBind(); List<dtLink> linkList=db.dtLink.OrderByDescending(l=>l.Id).OrderByDescending(l=>l.NSort).ToList(); online_linksRepeater.DataSource = linkList; online_linksRepeater.DataBind(); }