1 Star 1 Fork 0

messense / WebFormBlog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Category.aspx.cs 1.86 KB
一键复制 编辑 Web IDE 原始数据 按行查看 历史
messense 提交于 2013-07-26 17:49 . add namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebFormBlog
{
public partial class Category : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int catid = Convert.ToInt32(Request.QueryString["id"]);
if (catid <= 0)
{
throw new HttpException(404, "Category not found");
}
/*
BlogDataSetTableAdapters.categoryTableAdapter cta = new BlogDataSetTableAdapters.categoryTableAdapter();
BlogDataSet.categoryDataTable cdt = cta.GetDataById(catid);
if (cdt.Rows.Count < 1)
{
throw new HttpException(404, "Category not found");
}
PageTitleLiteral.Text = cdt.Rows[0]["title"].ToString();
CategoryNameLiteral.Text = cdt.Rows[0]["title"].ToString();
BlogDataSetTableAdapters.postTableAdapter pta = new BlogDataSetTableAdapters.postTableAdapter();
PostListRepeater.DataSource = pta.GetDataByCategoryId(catid);
PostListRepeater.DataBind();
*/
BlogModel.BlogEntities db = new BlogModel.BlogEntities();
var category = db.categories.SingleOrDefault(t => t.id == catid);
if (category == null)
throw new HttpException(404, "Category not found");
PageTitleLiteral.Text = category.title;
CategoryNameLiteral.Text = category.title;
var posts = from post in db.posts
where post.catid == catid
orderby post.id descending
select post;
PostListRepeater.DataSource = posts;
PostListRepeater.DataBind();
}
}
}
C#
1
https://gitee.com/messense/webformblog.git
git@gitee.com:messense/webformblog.git
messense
webformblog
WebFormBlog
master

搜索帮助

14c37bed 8189591 565d56ea 8189591