温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:I-favourite2.0多用户博客系统源码
当前文件:
iFavourite20/Admin/AlbumList.aspx.cs[3K,2009-6-12 11:44:57],打开代码结构图
iFavourite20/Admin/AlbumList.aspx.cs[3K,2009-6-12 11:44:57],打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using Spaces; 12
using Spaces.Controls; 13
public partial class Admin_AlbumList : AdminPage 14
{ 15
string pathFormat = string.Empty; 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
rprAlbumList.ItemCreated += new RepeaterItemEventHandler(rprAlbumList_ItemCreated); 19
rprAlbumList.ItemCommand += new RepeaterCommandEventHandler(rprAlbumList_ItemCommand); 20
//if (!IsPostBack) 21
//{ 22
pathFormat = string.Format("{0}/{1}/{2}/small/{3}", Config.GetConfig().PhotosUrl, User.Identity.Name, "{0}", "{1}"); 23
BindAlbums(); 24
// } 25
} 26
27
void rprAlbumList_ItemCommand(object source, RepeaterCommandEventArgs e) 28
{ 29
if (e.CommandName.ToLower() == "delete") 30
{ 31
int id = Convert.ToInt32(e.CommandArgument); 32
Photos.DelCategory(id); 33
} 34
BindAlbums(); 35
} 36
37
void rprAlbumList_ItemCreated(object sender, RepeaterItemEventArgs e) 38
{ 39
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 40
{ 41
PhotoCategory c = e.Item.DataItem as PhotoCategory; 42
if (c != null) 43
{ 44
Image icon = e.Item.FindControl("CategoryIcon") as Image; 45
if (icon != null) 46
{ 47
if (c.MainPhotoID > 0) 48
icon.ImageUrl = string.Format(pathFormat, c.ID, c.Image); 49
else 50
icon.ImageUrl = string.Format("{0}/images/NoPhoto.gif", Globals.ApplicationPath); 51
} 52
HyperLink AlbumName = e.Item.FindControl("AlbumName") as HyperLink; 53
if (AlbumName != null) 54
{ 55
AlbumName.Text = c.Name; 56
AlbumName.NavigateUrl = string.Format("PhotoList.aspx?categoryID={0}", c.ID); 57
} 58
Literal NumPhotos = e.Item.FindControl("NumPhotos") as Literal; 59
if (NumPhotos != null) 60
{ 61
NumPhotos.Text = string.Format("{0}张", c.NumPhotos); 62
} 63
Literal Updated = e.Item.FindControl("Updated") as Literal; 64
if (Updated != null) 65
{ 66
Updated.Text = c.Updated.ToString("yy-M-dd hh:mm"); 67
} 68
HyperLink EditCategory = e.Item.FindControl("EditCategory") as HyperLink; 69
if (EditCategory != null) 70
{ 71
EditCategory.NavigateUrl = string.Format("PhotoClassEdit.aspx?CategoryID={0}", c.ID); 72
} 73
LinkButton lnkDelete = e.Item.FindControl("lnkDelete") as LinkButton; 74
if (lnkDelete != null) 75
{ 76
lnkDelete.CommandArgument = c.ID.ToString(); 77
if (c.NumPhotos > 0) 78
lnkDelete.OnClientClick = "alert('请先删除该目录下所有图片。');return false;"; 79
else 80
lnkDelete.OnClientClick = "return confirm('是否真的删除该目录?')"; 81
} 82
} 83
84
} 85
} 86
void BindAlbums() 87
{ 88
rprAlbumList.DataSource = Photos.GetCategories(User.Identity.Name); 89
rprAlbumList.DataBind(); 90
} 91
} 92







}