从dataview中删除行 [英] delete row from dataview

查看:171
本文介绍了从dataview中删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




当我遍历数据视图的记录时,我会根据

条件删除datarow。但是我不想在

循环结束之前提交这些删除。使用数据表,我只需设置row.delete()并在循环结束时调用

AcceptChanges。但是我怎么能用数据视图呢




谢谢

Hi,

As I loop through a dataview''s records, I delete datarow based on a
condition. However I don''t want to commit those deletions until the
loop ends. With a datatable, i would just set row.delete() and call
AcceptChanges when the loop ends. But how can I do that with a dataview
?

Thank you

推荐答案

Sam,


不要混淆AdoNet中的删除和删除字样。


删除标记a datarow将被acceptchanges或DA.Update删除。

删除从DataTable中删除数据行。


我不确定你在做什么,因为它对我来说似乎很奇怪,但是

你会有一个解决方案。

如果你这样做的话。


DataTable.AcceptChanges''假设其他行状态可以设置为此

drv(0)。删除

DataTable.AcceptChanges


比第一行fullfils rowfilter将被删除。


这与

DataTable.rows.remove(drv( 0).row)


我希望这会有所帮助,


Cor


" Sam" ; < SA ************* @ googlemail.com> schreef在bericht

新闻:11 ********************** @ i40g2000cwc.googlegr oups.com ...
Sam,

Don''t mix up the words Delete and Remove in AdoNet.

Delete marks a datarow as to be Removed by an acceptchanges or an DA.Update.
Remove removes a datarow from a DataTable.

I am not sure what you are doing, because it seems strange to me, however
you will have a solution with this.
If you do by instance this.

DataTable.AcceptChanges ''assuming that al other rowstates can be set to this
drv(0).Delete
DataTable.AcceptChanges

Than the first row that fullfils the rowfilter will be removed.

Which is than the same as
DataTable.rows.remove(drv(0).row)

I hope this helps,

Cor

"Sam" <sa*************@googlemail.com> schreef in bericht
news:11**********************@i40g2000cwc.googlegr oups.com...


当我遍历数据视图的记录时,我会根据
条件删除datarow。但是我不想在
循环结束之前提交这些删除。使用数据表,我只需设置row.delete()并在循环结束时调用
AcceptChanges。但是我怎么能用数据视图来做呢

谢谢
Hi,

As I loop through a dataview''s records, I delete datarow based on a
condition. However I don''t want to commit those deletions until the
loop ends. With a datatable, i would just set row.delete() and call
AcceptChanges when the loop ends. But how can I do that with a dataview
?

Thank you



Cor,

感谢您的回复。

对不起,我不明白你的例子。也许我没有&b
正确解释了我想要做什么。

观看:


每行作为datarowview在myDataView中


如果我的条件满足则

标记行要删除

结束如果


下一步


在这里提交更改,意味着从myDataView中删除行。


现在,我想出了一个解决方案,即使用ToTable函数将dataview转换为
a数据表。然后我可以在这个数据表上使用.Delete和

AcceptChanges,然后将数据表重新分配为

我的数据视图的源代码。我知道它有点尴尬,但它是最好的

我能想到的。你有更好的解决方案吗?


Sam

Cor,
Thanks for replying.
I''m sorry but I don''t understand your example. Maybe I haven''t
explained properly what I want to do.
Watch this:

For each row as datarowview in myDataView

if my condition is met then
mark row to be removed
end if

Next

commit changes here, meaning remove the rows from myDataView.

Now, I''ve come up with a solution, which is to convert the dataview to
a datatable using ToTable function. Then I can use .Delete and
AcceptChanges on this datatable, and then reassign the datattable to be
the source for my dataview. I know it''s a bit ackward but it''s the best
I could come up with. Do you have a better solution ?

Sam


嗨Sam,


如果我理解你的问题,你想在视图中迭代

行,删除其中的一些(有条件地),然后提交

那些删除。希望下面的代码能解决你的问题。


Dim Row As DataRowView


视图中的每一行

如果条件=真然后

Row.Delete()

结束如果

下一页

View.Table.AcceptChanges( )

Hi Sam,

If I understand your question correctly, you want to iterate through
the rows in a view, delete some of them (conditionally), then commit
those deletes. Hopefully the code below solves your question.

Dim Row As DataRowView

For Each Row In View
If Condition = True Then
Row.Delete()
End If
Next
View.Table.AcceptChanges()


这篇关于从dataview中删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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