myPlace

begin Dotnet

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
protected void DataGrid1_EditCommand(object source, DataGridCommandEventArgs e)
    {
        DataGrid1.EditItemIndex = e.Item.ItemIndex;
        bond();
    }
    protected void DataGrid1_CancelCommand(object source, DataGridCommandEventArgs e)
    {
        DataGrid1.EditItemIndex = -1;
        bond();
    }

    protected void DataGrid1_UpdateCommand(object source, DataGridCommandEventArgs e)
    {
        string id = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
        string name = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
        string aaa = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
        string sql = "update Employees set LastName='" + name + "', FirstName='" + aaa + "' where EmployeeID=id";
        SqlConnection myconn=new SqlConnection("server=(local);database=Northwind;uid=sa;pwd=");
        SqlCommand comm = new SqlCommand(sql, myconn);
        myconn.Open();

        comm.ExecuteNonQuery();
        myconn.Close();
    }

posted on 2007-03-20 19:28  郝志杰  阅读(568)  评论(0)    收藏  举报