我用的是Microsoft Visual Studio 2005
新手,发发代码

解决方案 »

  1.   

    GridView 你修改 添加 删除 都在数据源里操作,..
      

  2.   

    删除修改在gridview 的属性中就可以设置allowedit,allowdelete添加你就要操作数据元了
      

  3.   

    winform
    or
    web
    的?
      

  4.   

    protected void profileGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            profileGridView.PageIndex = e.NewPageIndex;
            gvBind();
        }
        protected void profileGridView_RowEditing(object sender, GridViewEditEventArgs e)
        {
            profileGridView.EditIndex = e.NewEditIndex;
            gvBind();
        }
        protected void profileGridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            profileGridView.EditIndex = -1;
            gvBind();
        }    protected void profileGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string destination = ((TextBox)profileGridView.Rows[e.RowIndex].Cells[0].Controls[0]).Text;
            string ship = ((TextBox)profileGridView.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
            string myStr = 连接语句
            string SqlStr = "update 语句
            try
            {
                OleDbConnection conn = new OleDbConnection(myStr);            OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = conn;
                cmd.CommandText = SqlStr;
                cmd.CommandType = CommandType.Text;
                cmd.CommandTimeout = 10;
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                int i = cmd.ExecuteNonQuery();
                //if (conn.State == ConnectionState.Open)
                conn.Close();
                profileGridView.EditIndex = -1;
                gvBind();
            }
            catch (Exception ex)
            {
                Response.Write("数据库错误,错误原因:" + ex.Message);
                Response.End();
            }
           
        }
        protected void profileGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            
            DeleteAdminInfo(itemId);
            gvBind();
        }
        public void DeleteAdminInfo(string itemId)
        {
           string myStr = 链接字符
           OleDbConnection conn = new OleDbConnection(myStr);        OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = conn;
            cmd.CommandText =  delete 语句        cmd.CommandType = CommandType.Text;
            //添加参数
            OleDbParameter id = new OleDbParameter(":profile_id", OleDbType.Char, 36);
            id.Value = itemId;
            cmd.Parameters.Add(id);
            //执行过程
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
        }
      

  5.   

    谁教下QQ233168121
    或者发QQ我加下~