📄 listbycategory4.ascx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace MySite.WebUI.Controls.Article
{
using SubSonic.Generated;
using SubSonic;
using System.Collections.Generic;
using MySite.Utils;
/// <summary>
/// 用户显示客户的留言信息,直接显示内容,没有标题
/// </summary>
public partial class ListByCategory4 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.Add21.CategoryName = this.CategoryName;
this._GetRecordCount();
this._DataBind();
}
}
private void _DataBind()
{
this.Repeater1.DataSource = this._BindDS();
this.Repeater1.DataBind();
}
private ArticleCollection _BindDS()
{
Category cate = new Category(Category.Columns.Name, CategoryName);
if (cate.IsNew)
return new ArticleCollection();
else
{
//使用储存过程
System.Data.IDataReader dr = SPs.GetPagingCategoryRelveantArticles(new int?(cate.PKId), this.AspNetPager1.StartRecordIndex, this.AspNetPager1.EndRecordIndex, false).GetReader();
ArticleCollection ac = new ArticleCollection();
ac.LoadAndCloseReader(dr);
return ac;
}
}
private void _GetRecordCount()
{
Category cate = new Category(Category.Columns.Name, ViewState["CategoryName"]);
if (cate.IsLoaded)
this.AspNetPager1.RecordCount = Convert.ToInt32(SPs.GetPagingCategoryRelveantArticles(new int?(cate.PKId), null, null, true).ExecuteScalar());
else
this.AspNetPager1.RecordCount = 0;
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Repeater re = e.Item.FindControl("Repeater2") as Repeater;
if (e.Item.ItemType == ListItemType.Item)
{
Article arti = new Article(DataBinder.Eval(e.Item.DataItem, "PKId"));
re.DataSource = arti.GetCommentCollection();
re.DataBind();
}
}
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
this._DataBind();
}
public string CategoryName
{
get { return Convert.ToString(ViewState["CategoryName"]); }
set { ViewState["CategoryName"] = value; }
}
public string CssName
{
get { return ViewState["CssName"].ToString(); }
set { this.ViewState["CssName"] = value; }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -