📄 catalogmanage.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Web2ASPNET2.WebTags;
using Web2ASPNET2.CommonOperation;
using Web2ASPNET2.UserCommonOperation;
public partial class Portal_CatalogManage:System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{ ///判断用户是否登录
UserInfo info = (UserInfo)UserCommonOperation.GetUserInfo(Session);
if(info == null)
{ ///返回到上一个页面
Response.Write("<script>history.back()</script>");
///跳转到登录页面
Server.Transfer("~/Portal/UserLogin.aspx");
return;
}
///绑定控件的数据
if(!Page.IsPostBack)
{
BindPageData();
}
}
private void BindPageData()
{ ///绑定控件的数据
Tag tag = new Tag();
Web2ASPNET2.CommonOperation.DataBinder.BindGridViewData(
gvCatalog,tag.GetCatalogs());
}
protected void gvCatalog_RowDataBound(object sender,GridViewRowEventArgs e)
{ ///为删除按钮添加确认对话框
ImageButton ibtDelete = (ImageButton)e.Row.FindControl("ibtDelete");
if(ibtDelete != null)
{
ibtDelete.Attributes.Add("onclick","return confirm('你确定要删除所选择的数据行吗?');");
}
}
protected void gvCatalog_RowCommand(object sender,GridViewCommandEventArgs e)
{
if(e.CommandName == "update")
{
Server.Transfer("~/Portal/UpdateCatalog.aspx?CatalogID=" + e.CommandArgument.ToString());
}
if(e.CommandName == "del")
{ ///执行删除操作
Tag tag = new Tag();
tag.DeleteCatalog(DataTypeConvert.ConvertToInt(e.CommandArgument.ToString()));
///重新绑定控件数据
BindPageData();
}
}
protected void btnAdd_Click(object sender,EventArgs e)
{ ///页面重定向
Server.Transfer("~/Portal/AddCatalog.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -