我的dgv不会立即更新

我的dgv不会立即更新

本文介绍了我的dgv不会立即更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用windows form&我在我的表单上有一个dgv,我将它填充为menualy并在项目中使用linq到sql(c#project)但是当我执行我的update_sp并再次填充dgv时,我的dgv没有更新,我应该关闭dgv容器形成并重新打开它以查看我更新的tbl ...



我可以做些什么来解决这个问题?



我的sp_update呼叫代码:



 DataClassesDataContext dc =  new  DataClassesDataContext(); 
dc.sp_tblbooks_update(radif,txttitle.Text,txtauthor.Text,txttranslator.Text,txtsubject.Text,txtpublicator.Text,txtpublicatonyear.Text, bool 。 Parse(cmbavailable.Text),txtdescription.Text);
dc.SubmitChanges();
this .Close();



当我的表单关闭时,我调用linq select命令从db获取数据并重新填充dg:

  var  showbooksquery = 
来自 books in db.tblbooks
选择书籍;
dataGridView1.DataSource = showbooksquery;





注*选择(搜索)& insert命令工作正常,但更新没有..

我认为这是因为在操作运行时锁定表...但我不知道如何处理这个问题.. 。

plzz help

解决方案




Hi

I'm using windows form & I have a dgv on my form that I fill it menualy and I use linq to sql in my project(c# project) but when I execute my update_sp and fill the dgv again, my dgv isn't updated and I should close the dgv container form and reopen it to see my updated tbl ...

What can I do for solving this problem?

my sp_update calling codes:

DataClassesDataContext dc = new DataClassesDataContext();
dc.sp_tblbooks_update(radif, txttitle.Text, txtauthor.Text, txttranslator.Text, txtsubject.Text, txtpublicator.Text, txtpublicatonyear.Text, bool.Parse(cmbavailable.Text), txtdescription.Text);
dc.SubmitChanges();
this.Close();


and when my form is closed,I call a linq select command to get data from db and refill the dg:

var showbooksquery =
               from books in db.tblbooks
               select books;
           dataGridView1.DataSource = showbooksquery;



Note* select(search) & insert command work properly but update doesn't..
I think it is because of locking the table when an operation is running... but I don't know how to deal with this problem...
plzz help

解决方案




这篇关于我的dgv不会立即更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 11:36