您目前尚未登陆,请选择【登陆】或【注册
首页->其他源码->内文广告管理系统V1.1版源码>>admin2.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:内文广告管理系统V1.1版源码
当前文件:文件类型 TextAd/admin2.aspx.cs打开代码结构图
普通视图
		            
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; 11public partial class admin2 : System.Web.UI.Page 12{ 13 //该 源 码下载自www.51aspx.com(51aspx.c om) 14 protected void Page_Load(object sender, EventArgs e) 15 { 16 //没有登录,则转向登录 17 if (Session["admin"]==null||Session["admin"].ToString() != "true") Response.Redirect("login.aspx"); 18 if (!IsPostBack) 19 { 20 myDataBind();//绑定数据 21 } 22 } 23 //分页 24 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 25 { 26 GridView1.PageIndex = e.NewPageIndex; 27 myDataBind(); 28 } 29 //删除 30 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 31 { 32 if (e.CommandName == "del") 33 { 34 string id = e.CommandArgument.ToString(); 35 try 36 { 37 Sql s = new Sql(); 38 s.ExecuteSql("delete from ad where id=" + id);//删除 39 myDataBind(); 40 } 41 catch 42 { } 43 } 44 } 45 //绑定数据源 46 private void myDataBind() 47 { 48 Sql s = new Sql(); 49 string str = "select ad.*,keyarray.name from ad inner join keyarray on ad.keyid=keyarray.id order by ad.id desc"; 50 DataSet ds = s.getMyDataSet(str);//所有广告内容 51 GridView1.DataSource = ds; 52 GridView1.DataBind(); 53 } 54 //添加广告内容 55 protected void Button1_Click(object sender, EventArgs e) 56 { 57 int result; 58 Sql s = new Sql(); 59 //添加广告内容 60 result =s.ExecuteSql("insert into ad(keyid,description,url) values('"+ DropDownList1.SelectedValue +"','"+ TextBox2.Text+"','"+ TextBox1.Text+"')"); 61 string msg = "alert('操作错误!')"; 62 if (result==1)//如果操作成功,提示 63 { 64 TextBox2.Text = TextBox1.Text = ""; 65 msg = "alert('操作成功!')"; 66 myDataBind(); 67 } 68 //客户端提示 69 ClientScript.RegisterStartupScript(this.GetType(), "asdf", msg, true); 70 } 71} 72
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:内文广告管理系统V1.1版源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号