简体   繁体   中英

C# Update DataGridView after SubmitChanges()

I've got this piece of code to update dataGridView after adding an Item.

dbContext.Item.InsertOnSubmit(new Item());
dbContext.SubmitChanges();
dataGridView1.DataSource = null;
dataGridView1.DataSource = dbContext.Item;

It's a great mystery to me why nothing happens when I'm trying to use it more than once...

I'm not 100% clear on what your experiencing, I'm going to assume its that the gridview is not showing the new additional item.

Have you tried calling refresh on that gridview?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM