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:数据库更改后如何刷新网格视图
基础教程推荐
- C# 从 List<List<int>> 中删除重 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
