📄 categorylist.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 Surance.DB4ODAL;
using Surance.DBUtility;
using Db4objects.Db4o;
public partial class Back_CategoryList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
IObjectContainer db = DB4OHelper.DB;
try
{
Category c = new Category(db);
GridView1.DataSource = c.GetAll();
GridView1.DataBind();
}
catch
{
}
finally
{
db.Close();
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument.ToString().Trim());
string module = GridView1.Rows[index].Cells[0].Text.Trim();
string name = GridView1.Rows[index].Cells[1].Text.Trim();
IObjectContainer db = DB4OHelper.DB;
Category c = new Category(db);
c.Module = module;
c.Name = name;
try
{
Category c2 = c.GetOne(c);
if (c2 != null)
{
c.Del(c2);
}
}
catch
{
}
finally
{
db.Close();
}
BindGrid();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowIndex > -1)
{
LinkButton b = (LinkButton)e.Row.Cells[2].Controls[0];
b.Attributes.Add("onClick", "javascript:return confirm('Are you sure to delete?');");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -