温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.0正式版源码
当前文件:
SpaceBuiderV10Source/BlogControls/Views/ArchiveList.cs,打开代码结构图
SpaceBuiderV10Source/BlogControls/Views/ArchiveList.cs,打开代码结构图1//------------------------------------------------------------------------------ 2
// <copyright company="Tunynet"> 3
// Copyright (c) Tunynet Network Technology Co., Ltd. All rights reserved. 4
// </copyright> 5
//------------------------------------------------------------------------------ 6
7
using System; 8
using System.Collections.Generic; 9
using System.Text; 10
using System.Web.UI.WebControls; 11
using System.Collections; 12
using SpaceBuilder.Blogs.Components; 13
14
namespace SpaceBuilder.Blogs.Controls 15
{ 16
public class ArchiveList : WeblogThemedControl 17
{ 18
Repeater archiveListRepeater; 19
protected override void AttachChildControls() 20
{ 21
archiveListRepeater = FindControl("ArchiveListRepeater") as Repeater; 22
archiveListRepeater.ItemDataBound += new RepeaterItemEventHandler(ArchiveListRepeater_ItemDataBound); 23
} 24
25
protected override void OnLoad(EventArgs e) 26
{ 27
base.OnLoad(e); 28
EnsureChildControls(); 29
if (!Page.IsPostBack) 30
DataBind(); 31
} 32
33
public override void DataBind() 34
{ 35
base.DataBind(); 36
Bind(); 37
} 38
39
public void Bind() 40
{ 41
List<ArchiveDataItem> list = BlogPosts.GetStatByMonths(CurrentWeblog.SectionID); 42
archiveListRepeater.DataSource = list; 43
archiveListRepeater.DataBind(); 44
} 45
46
void ArchiveListRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) 47
{ 48
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 49
{ 50
ArchiveDataItem item = e.Item.DataItem as ArchiveDataItem; 51
if (item == null) 52
return; 53
54
HyperLink archiveLink = e.Item.FindControl("ArchiveLink") as HyperLink; 55
if (archiveLink != null) 56
{ 57
archiveLink.Text = item.Date.ToString("yyyy年MM月"); 58
archiveLink.NavigateUrl = BlogUrls.Instance().ShowBlogPostByMonth(CurrentWeblog.ApplicationKey, item.Date); 59
} 60
61
Literal itemCount = e.Item.FindControl("ItemCount") as Literal; 62
if (itemCount != null) 63
itemCount.Text = item.Count.ToString(); 64
} 65
} 66
67
68
} 69
} 70





}
}