📄 essay.ascx.cs
字号:
namespace WesternByte.MyBlog.Controls.Blog
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using WesternByte.MyBlog.Core.Essay;
using WesternByte.MyBlog.Core.Category;
/// <summary>
/// Essay 的摘要说明。
/// </summary>
public class Essay : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DataList essayCategory;
protected System.Web.UI.WebControls.DataList essayDoc;
protected System.Web.UI.HtmlControls.HtmlTable enoCount;
protected System.Web.UI.HtmlControls.HtmlTable ednoCount;
protected EssayDAO eDAO = new EssayDAO();
protected CategoryDAO cDAO = new CategoryDAO();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
int BlogID = Convert.ToInt32(Page.Request.QueryString["BlogID"]);
DataSet ecDs = cDAO.LoadList(BlogID,"e");
ecDs.Tables[0].Columns.Add("CategoryStr");
for(int i=0;i<ecDs.Tables[0].Rows.Count;i++)
{
ecDs.Tables[0].Rows[i]["CategoryStr"] = "<a href=\"Essay.aspx?BlogID=" + BlogID + "&CategoryID=" + ecDs.Tables[0].Rows[i]["CategoryID"].ToString() + "\">" + ecDs.Tables[0].Rows[i]["Name"].ToString() + " (" + eDAO.LoadCount(BlogID,Convert.ToInt32(ecDs.Tables[0].Rows[i]["CategoryID"].ToString()),"","") + ")</a>";
}
essayCategory.DataSource = ecDs.Tables[0].DefaultView;
essayCategory.DataBind();
if(ecDs.Tables[0].Rows.Count==0)
{
enoCount.Visible = true;
}
else
{
enoCount.Visible = false;
}
DataSet edDs = eDAO.LoadMonth(BlogID);
edDs.Tables[0].Columns.Add("Doc");
for(int i=0;i<edDs.Tables[0].Rows.Count;i++)
{
edDs.Tables[0].Rows[i]["Doc"] = "<a href=\"Essay.aspx?BlogID=" + BlogID + "&Doc=" + edDs.Tables[0].Rows[i]["Time"].ToString() + "\">" + edDs.Tables[0].Rows[i]["Time"].ToString().Substring(0,4) + "年" + Convert.ToInt32(edDs.Tables[0].Rows[i]["Time"].ToString().Substring(5)) + "月 (" + edDs.Tables[0].Rows[i]["Count"].ToString() + ")</a>";
}
essayDoc.DataSource = edDs.Tables[0].DefaultView;
essayDoc.DataBind();
if(edDs.Tables[0].Rows.Count==0)
{
ednoCount.Visible = true;
}
else
{
ednoCount.Visible = false;
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -