📄 introductionlist.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 IntroductionList : System.Web.UI.Page
{
private string editUrl = "IntroductionUpdate.aspx?Title=";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{ IObjectContainer db = DB4OHelper.DB;
try
{
Introduction intro = new Introduction(db);
GridView1.DataSource = intro.GetAll();
GridView1.DataBind();
}
catch
{
}
finally
{
db.Close();
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument.ToString().Trim());
string title = GridView1.Rows[index].Cells[0].Text.Trim();
switch (e.CommandName)
{
case "Edit":
{
Response.Redirect(editUrl + title);
break;
}
case "Del":
{
Del(index,title);
break;
}
}
}
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[5].Controls[0];
b.Attributes.Add("onClick", "javascript:return confirm('Are you sure to delete?');");
}
}
}
private void Del(int index, string title)
{
IObjectContainer db = DB4OHelper.DB;
Introduction intro = new Introduction(db);
// intro.Title = title;
try
{
Introduction intro2 = intro.GetOne(title);
if (intro2 != null)
{
intro.Del(intro2);
}
}
catch
{
}
finally
{
db.Close();
}
BindGrid();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -