如楼上所述,我没写代码= =,form_load中的代码是这样的: // TODO: This line of code loads data into the 'studentinfoDataSet.sinfo' table. You can move, or remove it, as needed. this.sinfoTableAdapter.Fill(this.studentinfoDataSet.sinfo); 我把这段代码剪切到button_click中居然没用,上面注释不是说可以remove吗?另外:重新绑定的代码要怎么写呢?
DataTable dt=你数据库查询的数据
this.dataGridView1.DataSource =dt;
// TODO: This line of code loads data into the 'studentinfoDataSet.sinfo' table. You can move, or remove it, as needed.
this.sinfoTableAdapter.Fill(this.studentinfoDataSet.sinfo);
我把这段代码剪切到button_click中居然没用,上面注释不是说可以remove吗?另外:重新绑定的代码要怎么写呢?
就是直接在datagridview上Add一个新的row,看上去像从数据库里面提取来的一样~~ 如果能保证数据正确添加到数据库这样没问题了。
然后添加datagridview里边,dataset ds=;
for (int shu=0;shu<ds.tables[0].rows.count,shu++)
{
datagridviewrow row=new datagrideviewrow();
row.createcell(dgv);string name=ds.tables[0].rows[shu].cells[0].value.tostring();
row.celss[0].value=name;
dgv.rows.add(row);
}
这句话就是说你 已经给dgv添加数据了,不能再次添加行了,
就好像人已经穿上衣服了,就没办法试穿其他的了