问题描述
代码在这里usingSystem;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Web;usingSystem.Web.SessionState;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.HtmlControls;usingHongSheng.Common;namespaceHongSheng.Admin{///<summary>///Admin_Message的摘要说明。///</summary>publicclassAdmin_Message:System.Web.UI.Page{protectedSystem.Web.UI.WebControls.Buttonbtn_search;protectedSystem.Web.UI.WebControls.TextBoxtxt_content;protectedSystem.Web.UI.WebControls.LabelLabel1;protectedSystem.Web.UI.WebControls.LabelLabel2;protectedSystem.Web.UI.WebControls.LabelLabel3;protectedSystem.Web.UI.WebControls.DataGridDataGrid1;privatevoidPage_Load(objectsender,System.EventArgse){if(!Page.IsPostBack){BindDataInfo();}//在此处放置用户代码以初始化页面}#regionWeb窗体设计器生成的代码overrideprotectedvoidOnInit(EventArgse){////CODEGEN:该调用是ASP.NETWeb窗体设计器所必需的。//InitializeComponent();base.OnInit(e);}///<summary>///设计器支持所需的方法-不要使用代码编辑器修改///此方法的内容。///</summary>privatevoidInitializeComponent(){this.btn_search.Click+=newSystem.EventHandler(this.btn_search_Click);this.DataGrid1.DeleteCommand+=newSystem.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);this.DataGrid1.SelectedIndexChanged+=newSystem.EventHandler(this.DataGrid1_SelectedCommand);this.Load+=newSystem.EventHandler(this.Page_Load);}#endregionDataBaseobdatabase=newDataBase();stringMessagesql;stringSearchsql;privatevoidBindDataInfo(){Messagesql="select*fromMessage";DataGrid1.DataSource=obdatabase.CreateTable(Messagesql);DataGrid1.DataBind();}privatevoidDataGrid1_DeleteCommand(objectsource,System.Web.UI.WebControls.DataGridCommandEventArgse){boolflag=false;stringnid=DataGrid1.DataKeys[e.Item.ItemIndex].ToString();Messagesql="DELETEMessageWHEREMessageId='"+nid+"'";if(flag=this.obdatabase.UpDateTable(Messagesql)){this.DataGrid1.Attributes.Add("onclick","returnconfirm('确实要删除设备吗?')");}else{this.RegisterStartupScript("start","<scriptlanguage=javascript>alert('删除失败!');window.location.href=document.URL;</script>");}BindDataInfo();}privatevoidDataGrid1_SelectedCommand(objectsender,System.EventArgse){Response.Redirect("Admin_Message_Restore.aspx");}privatevoidbtn_search_Click(objectsender,System.EventArgse){Searchsql="select*WHEREMessage_Contentlike'%"+this.txt_content.Text+"%'";DataGrid1.DataSource=obdatabase.CreateTable(Searchsql);DataGrid1.DataBind();}}}