温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:ajax奥运留言本v1.0源码
当前文件:
OlympicBook/RoleByAccess/main.aspx.cs[2K,2009-6-12 11:51:24],打开代码结构图
OlympicBook/RoleByAccess/main.aspx.cs[2K,2009-6-12 11:51:24],打开代码结构图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.OleDb; 12
public partial class admin_main : System.Web.UI.Page 13
{ 14
OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString); 15
DataBase db = new DataBase(); 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
19
if(!this.Page.IsPostBack) 20
{ 21
this.ShowInfo(); 22
} 23
} 24
private void ShowInfo() 25
{ 26
string str = "select * from message"; 27
OleDbDataAdapter da = new OleDbDataAdapter(str,conn); 28
DataSet ds = new DataSet(); 29
da.Fill(ds,"a"); 30
this.GridView1.DataSource = ds.Tables["a"].DefaultView; 31
this.GridView1.DataKeyNames = new string[] { "id" }; 32
this.GridView1.DataBind(); 33
} 34
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 35
{ 36
this.GridView1.PageIndex = e.NewPageIndex; 37
this.ShowInfo(); 38
} 39
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 40
{ 41
string sql = "select * from message"; 42
OleDbDataAdapter da = new OleDbDataAdapter(sql,conn); 43
OleDbCommandBuilder oc = new OleDbCommandBuilder(da); 44
DataSet ds = new DataSet(); 45
da.Fill(ds,"b"); 46
DataRow row = ds.Tables["b"].Rows[e.RowIndex]; 47
row.Delete(); 48
da.Update(ds,"b"); 49
this.ShowInfo(); 50
} 51
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 52
{ 53
if(e.Row.RowType==DataControlRowType.DataRow) 54
{ 55
if (e.Row.Cells[4].Text.Trim() == "0") 56
{ 57
e.Row.Cells[4].Text = "<font color=red>隐藏</font>"; 58
} 59
else 60
{ 61
e.Row.Cells[4].Text = "公开"; 62
} 63
if (e.Row.Cells[5].Text.Trim() == "0") 64
{ 65
e.Row.Cells[5].Text = "<font color=red>新留言</font>"; 66
} 67
else 68
{ 69
e.Row.Cells[5].Text = "已回复"; 70
} 71
((LinkButton)(e.Row.Cells[6].Controls[0])).Attributes.Add("onclick","return confirm('确定要删除吗?')"); 72
} 73
} 74
} 75





OleDbConnection conn 
}
}