?? href.aspx.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Wuqi.Webdiyer;
using WesternByte.MyBlog.Core.Blog;
using WesternByte.MyBlog.Core.Category;
using WesternByte.MyBlog.Core.Href;
namespace WesternByte.MyBlog.Blog.Admin.Href
{
/// <summary>
/// Href 的摘要說明。
/// </summary>
public class Href : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataList hrefCategory;
protected System.Web.UI.WebControls.DataList hrefList;
protected Wuqi.Webdiyer.AspNetPager pager;
protected HrefDAO hDAO = new HrefDAO();
protected CategoryDAO cDAO = new CategoryDAO();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
if(Session["Blog"]!=null)
{
BlogVO bVO = (BlogVO)Session["Blog"];
if(!Page.IsPostBack)
{
string Category = Page.Request.QueryString["CategoryID"];
int CategoryID = 0;
if(Category != null) CategoryID = Convert.ToInt32(Category);
pager.RecordCount = hDAO.LoadCount(bVO.BlogID,CategoryID);
BindData(bVO.BlogID,CategoryID);
}
}
else
{
Page.Response.Redirect("/Login.aspx");
}
}
private void BindData(int BlogID,int CategoryID)
{
//分類列表
DataSet cDs = cDAO.LoadList(BlogID,"h");
cDs.Tables[0].Columns.Add("CategoryStr");
for(int i=0;i<cDs.Tables[0].Rows.Count;i++)
{
cDs.Tables[0].Rows[i]["CategoryStr"] = "<a href=\"Href.aspx?CategoryID="+cDs.Tables[0].Rows[i]["CategoryID"].ToString()+"\">"+cDs.Tables[0].Rows[i]["Name"].ToString()+"</a>";
}
this.hrefCategory.DataSource = cDs.Tables[0].DefaultView;
this.hrefCategory.DataBind();
//當前分類下所有隨筆列表
DataSet hDs = hDAO.LoadList(BlogID,CategoryID,pager.PageSize*(pager.CurrentPageIndex-1),pager.PageSize);
hDs.Tables[0].Columns.Add("Category");
hDs.Tables[0].Columns.Add("Edit");
hDs.Tables[0].Columns.Add("Remove");
for(int i=0;i<hDs.Tables[0].Rows.Count;i++)
{
hDs.Tables[0].Rows[i]["Category"] = cDAO.Load(Convert.ToInt32(hDs.Tables[0].Rows[i]["CategoryID"])).Name;
hDs.Tables[0].Rows[i]["Url"] = "<a href=\"http://" + hDs.Tables[0].Rows[i]["Url"].ToString() + "\" target=\"_blank\">" + hDs.Tables[0].Rows[i]["Url"].ToString() + "</a>";
hDs.Tables[0].Rows[i]["Edit"] = "<a href=\"Edit.aspx?HrefID=" + hDs.Tables[0].Rows[i]["HrefID"].ToString() + "\">修改</a>";
hDs.Tables[0].Rows[i]["Remove"] = "<a href=\"Remove.aspx?HrefID=" + hDs.Tables[0].Rows[i]["HrefID"].ToString() + "\">刪除</a>";
}
hrefList.DataSource = hDs.Tables[0].DefaultView;
hrefList.DataBind();
//動態設置用戶自定義文本內容
pager.CustomInfoText="共"+pager.PageCount.ToString()+"頁,當前為第"+pager.CurrentPageIndex.ToString()+"頁";
}
protected void ChangePage(object src,PageChangedEventArgs e)
{
string Category = Page.Request.QueryString["CategoryID"];
int CategoryID = 0;
if(Category != null) CategoryID = Convert.ToInt32(Category);
pager.CurrentPageIndex=e.NewPageIndex;
BindData(((BlogVO)Session["Blog"]).BlogID,CategoryID);
}
#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 + -