温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:社会标签(Tags)文章管理系统源码
当前文件:
TagsArticle/Portal/ArticleManage.aspx.cs,打开代码结构图
TagsArticle/Portal/ArticleManage.aspx.cs,打开代码结构图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 System.Data.SqlClient; 12
using Web2ASPNET2.WebTags; 13
using Web2ASPNET2.CommonOperation; 14
using Web2ASPNET2.UserCommonOperation; 15
16
public partial class Portal_ArticleManage:System.Web.UI.Page 17
{ 18
protected void Page_Load(object sender,EventArgs e) 19
{ ///判断用户是否登录 20
UserInfo info = (UserInfo)UserCommonOperation.GetUserInfo(Session); 21
if(info == null) 22
{ ///返回到上一个页面 23
Response.Write("<script>history.back()</script>"); 24
///跳转到登录页面 25
Server.Transfer("~/Portal/UserLogin.aspx"); 26
return; 27
} 28
///绑定控件的数据 29
if(!Page.IsPostBack) 30
{ 31
BindPageData(); 32
} 33
} 34
private void BindPageData() 35
{ ///绑定控件的数据 36
Tag tag = new Tag(); 37
Web2ASPNET2.CommonOperation.DataBinder.BindGridViewData( 38
gvArticle,tag.GetArticles()); 39
} 40
protected void gvArticle_RowDataBound(object sender,GridViewRowEventArgs e) 41
{ ///为删除按钮添加确认对话框 42
ImageButton ibtDelete = (ImageButton)e.Row.FindControl("ibtDelete"); 43
if(ibtDelete != null) 44
{ 45
ibtDelete.Attributes.Add("onclick","return confirm('你确定要删除所选择的数据行吗?');"); 46
} 47
} 48
protected void gvArticle_RowCommand(object sender,GridViewCommandEventArgs e) 49
{ 50
if(e.CommandName == "update") 51
{ 52
Server.Transfer("~/Portal/UpdateArticle.aspx?ArticleID=" + e.CommandArgument.ToString()); 53
} 54
if(e.CommandName == "del") 55
{ ///执行删除操作 56
Tag tag = new Tag(); 57
tag.DeleteArticle(DataTypeConvert.ConvertToInt(e.CommandArgument.ToString())); 58
///重新绑定控件数据 59
BindPageData(); 60
} 61
} 62
protected void btnAdd_Click(object sender,EventArgs e) 63
{ ///页面重定向 64
Server.Transfer("~/Portal/AddArticle.aspx"); 65
} 66
} 67





}
}