将数据从DataGrid保存到数据库 [英] Saving Data from datagrid into database

查看:227
本文介绍了将数据从DataGrid保存到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这个问题很可能是引起了恶心的问题,而我寻找解决方案的时间已经太久了.

请有人可以将我指向一篇文章或一些如何执行以下操作的代码示例.

我有一个带有数据网格的WPF页面(它有两个手动创建的列).我有一个ViewModel,它从数据库中的表中获取数据并填充datagrid(通过ObservableCollection).

我要做的就是编辑\添加\删除数据网格上的项目,然后将更改提交回数据库.我的可观察集合会编辑\添加\删除项目,但是如何通知这些更改呢?

Ok so this question has most probably asked ad nauseum and I have searched for a solution for far too long now.

please can someone point me to an article or some code examples of how to do the following.

I have a WPF page with a datagrid (it has two manually created columns) on it. I have a ViewModel which gets my data from a table in my database and populates the datagrid (through an ObservableCollection).

all i want to do is to edit\add\delete items on the datagrid and submit the changes back to the database. my observable collection does edit\add\delete items, but how the heck do I get notified of these changes?

thanks in advance.

推荐答案

如果要获取有关ObservableCollection更改的通知,可以注册到
If you want to get notified about the ObservableCollection changes, you can register to the CollectionChanged event of it.


这篇关于将数据从DataGrid保存到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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