我想知道如何在datagridview中更新已编辑的列或行?
这是我的代码,它显示我的datagridview但是当我编辑它并重新加载视图按钮时 它没有更新。
提前感谢您的帮助
public void button3_Click(object sender,EventArgs e)//查看 {
DataSet ds = new DataSet();
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter();
da = new OleDbDataAdapter("select * from Employees", con);
ds.Tables.Add(dt);
da.Fill(dt);
dataGridView1.DataSource = dt.DefaultView;
con.Close();
}
答案 0 :(得分:-1)
DataSet ds = new DataSet();
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(CMD);
da = new OleDbDataAdapter("select * from Employees", con);
ds.Tables.Add(dt);
da.Fill(dt,"EmployeeName");
dataGridView1.DataSource = dt.DefaultView;
dataGridView1.DataMember = "EmployeeName";
con.Close();