• DataGrid编辑删除取消


    {
     /// <summary>
     /// Update 的摘要说明。
     /// </summary>
     public class Update : System.Web.UI.Page
     {
      protected System.Web.UI.WebControls.DataGrid DG1;
      protected Classes.AreaInfo myClass=new Client.Classes.AreaInfo();
      private void Page_Load(object sender, System.EventArgs e)
      {
       if(!this.IsPostBack)
       {
        this.DG1.DataSource=myClass.bindGrid();
        this.DG1.DataBind();
       }
       // 在此处放置用户代码以初始化页面
      }
      public void Page_Grid(Object sender, DataGridPageChangedEventArgs e)
      {
       DG1.CurrentPageIndex = e.NewPageIndex;
       DG1.DataSource =myClass.bindGrid();
       DG1.DataBind();

      }
      public void DG1_Edit(Object sender, DataGridCommandEventArgs e)
      {
       DG1.EditItemIndex = e.Item.ItemIndex;
       DG1.DataSource =myClass.bindGrid();
       DG1.DataBind();

      }

      public void DG1_Cancel(Object sender, DataGridCommandEventArgs e)
      {   
       DG1.EditItemIndex = -1;
       DG1.DataSource = myClass.bindGrid();
       DG1.DataBind();

      }

      public void DG1_Update(Object sender, DataGridCommandEventArgs e)
      {
       string code = ((TextBox)e.Item.Cells[1].Controls[1]).Text;
       string name = ((TextBox)e.Item.Cells[2].Controls[1]).Text;
       int id=int.Parse(e.Item.Cells[0].Text);
       myClass.upDateArea(id,code,name);
       DG1.EditItemIndex = -1;
       DG1.DataSource = myClass.bindGrid();
       DG1.DataBind();
       

      }

      public void DG1_Delete(Object sender, DataGridCommandEventArgs e)
      {
       int id=int.Parse(e.Item.Cells[0].Text);
       myClass.deleteArea(id);
       this.DG1.DataSource=myClass.bindGrid();
       this.DG1.DataBind();

      }

  • 相关阅读:
    ElasticSearch(二) Transport Client Connection By Domain
    ElasticSearch(一) Transport Client
    如何把Spring Boot打包成war
    Lucene Query种类
    JAVA Http Basic auth
    Java 多线程系列2——多线程的生命周期及生产消费者模型
    Java 多线程系列1——浅聊JAVA 线程池的一般用法
    JS 实现右下角弹窗
    JS 实现兼容IE图片向左或向右翻转
    Vue Input输入框两侧加减框内数字组件
  • 原文地址:https://www.cnblogs.com/nianyuwen/p/3003728.html
Copyright © 2020-2023  润新知