Telerik gridview:数据库更改后如何刷新网格视图 [英] Telerik gridview : How to refresh grid view after Database change

查看:24
本文介绍了Telerik gridview:数据库更改后如何刷新网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C# winform 应用程序中使用 radgridview 来显示数据库中的数据.我还通过 ADO.Net 更改数据库.问题是在我更改数据库后,例如通过删除一行或添加新行,更改不会出现在 gridview 中.
我还想提一下,我已经通过智能标签将数据库绑定到 gridview,当我尝试创建一个新数据集并将其分配给 radgridview1.datasource 时,我遇到了很多错误.
关于如何强制 radgridview 重新加载它的 datasource 的任何建议?

I'm using radgridview in C# winform application to show data from database. I'm also altering database through ADO.Net. The problem is after I change the database, for example by deleting a row or adding a new row, changes do not appear in gridview.
I also want to mention that I have bound database to gridview through smart tags and when I tried to create a new dataset and assign it to radgridview1.datasource I got tons of errors.
Any suggestion on how can force radgridview to reload it's datasource ?

推荐答案

嗯,我自己找到了答案.虽然它只适用于 dataGridView 而不适用于 dataListView.
删除记录并提交对数据库的更改:

Well, I found the answer myself. Although it only works on dataGridView and doesn't work on dataListView.
To delete a record and commit changes to database :

radGridView1.CurrentRow.Delete();
this.yourTableAdapter.Update(yourDataSet);

另一方面,如果您添加了新记录并且您想重新整理列表:

On the other hand, if you have added new records and you want to reform the list :

this.yourTableAdapter.Fill(yourDataSet.yourTabel);

如果您知道如何对 dataListView 做同样的事情,我会很高兴听到.

If you know how to do the same with dataListView, I'll be glad to hear.

这篇关于Telerik gridview:数据库更改后如何刷新网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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