仅返回datagridview的更改的行? [英] Return only the changed rows of a datagridview?

查看:43
本文介绍了仅返回datagridview的更改的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含datagridview的winform.该表格已与数据完全断开.后面的代码调用一个Web服务,该服务返回一个表.该表成为datagridview的数据源.一旦显示了datagridview,用户就可以编辑他们想要的任何行.当前,当他们单击更新"按钮时,将返回网格中的每一行.

I have a winform that contains a datagridview. The form is totally disconnected from the data. The codebehind calls a webservice, which returns a table. That table becomes the datasource for the datagridview. Once the datagridview is displayed, a user can edit whichever rows they desire. Currently, when they hit the 'Update' button, every row in the grid is returned.

有没有办法只返回datagridview中更改的行?

Is there a way to return only the changed rows in the datagridview?

更新:根据下面的Tezzo的回答,我能够做到这一点:

UPDATE: Based off Tezzo's answer below, I was able to do this:

var changedRows = ((DataTable)dataGridView1.DataSource).GetChanges(DataRowState.Modified).Rows;

推荐答案

您可以使用 GetChanges DataTable 中检索更改.

You can retrieve changes in a DataTable using GetChanges.

因此您可以将此代码与 DataGridView 一起使用:

So you can use this code with a DataGridView:

CType(YourDataGridView.DataSource, DataTable).GetChanges(DataRowState.Modified).Rows

这篇关于仅返回datagridview的更改的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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