如上图点击了完后在GridView启用了修改功能
但运行过程中更新不了数据库没更新到页面也更新不了!

解决方案 »

  1.   

    还要绑定一下
    this.gridview1.databind()
      

  2.   

     protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    
                    this.GridView1.DataSource = ReturnDataTable("select * from tablename(你的表名)");
                    this.GridView1.DataBind();
                   
                }
            }
            /// <summary>
            /// 执行有参的查询 返回DataTable
            /// </summary>
            /// <returns>返回DataTable</returns>
            public static DataTable ReturnDataTable(string cmdtext)
            {
                SqlConnection cn = new SqlConnection();
                cn.ConnectionString = "数据库连接字符串";
                DataTable dt = new DataTable();
                SqlCommand cmd = new SqlCommand();
                cmd = new SqlCommand(cmdtext, cn);
                cmd.CommandType = CommandType.Text; ;
                SqlDataReader dr = null;
                using (dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    dt.Load(dr);
                }
                return dt;
            }