Telerik gridview : How to refresh grid view after Database change(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:数据库更改后如何刷新网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Telerik gridview:数据库更改后如何刷新网格视图


基础教程推荐
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01