Asp.net源码专业站
首页->留言本类->ajax奥运留言本v1.0源码>>RoleByAccess/main.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:ajax奥运留言本v1.0源码
当前文件:文件类型 OlympicBook/RoleByAccess/main.aspx.cs[2K,2009-6-12 11:51:24]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.OleDb; 12public 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
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:ajax奥运留言本v1.0源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146