我的dgv不会立即更新 [英] My dgv doesn't update immidiately

查看:85
本文介绍了我的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

解决方案

在提交更新后你没有显示刷新dgv的代码,所以我是假设您没有这样做?


解决方案取决于您正在使用的前端。您使用的是Windows窗体,Web,控制台等吗?

如果您使用的是Web,在这种情况下使用ASP.NET,则需要在填充dtg后刷新页面。您还可以使用动态控件作为Jquery或Ajax来仅更新dtg。


大家好,感谢您的回答我应该在showquery之前创建一个新的dbdatacontext实例...

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

解决方案

You don't show the code where you refresh the dgv after the update is commited, so I'm assuming you didn't do that?


The solution depends of the front end that you are using. Are you using windows forms, web, console or etc?
If you are using web, in that case ASP.NET, you will need to refresh the page after fill the dtg. You can also use a dynamic control as Jquery or Ajax to update only the dtg.


Hi guys thank u for ur answers I should make a new instance of dbdatacontext before showquery...


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆