📄 recommendlist.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;
using System.IO;
using Surance.Utility;
using Db4objects.Db4o.Query;
public partial class Back_RecommendList : System.Web.UI.Page
{
private string editUrl = "RecommendUpdate.aspx?Title=";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
IObjectContainer db = DB4OHelper.DB;
try
{
Recommend item = new Recommend();
item.Db = db;
IObjectSet sets = item.GetAll();
GridView1.DataSource = sets;
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(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(string title)
{
IObjectContainer db = DB4OHelper.DB;
Recommend item = new Recommend(db);
//string pictureName = string.Empty;
try
{
Recommend target = (Recommend)item.GetOne(title);
if (target != null)
{
target.Db = db;
//item.Del(target);
target.Del();
//pictureName = item.Picture;
}
}
catch (Exception e)
{
Response.Write(e.Message);
}
finally
{
db.Close();
}
//del the picture
//if (string.IsNullOrEmpty(pictureName))
//{
// File.Delete(Tools.GetPictureSavePath() + pictureName);
//}
BindGrid();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -