在 .NET 中创建断开连接的数据行
如何创建不与任何特定 DataTable 实例绑定的 DataRow 实例?
(编辑:我知道您可以使用 DataTable.NewRow() 方法创建 DataRows,但问题是我似乎无法将该行与其父表断开连接,因此我可以传递单个行而不必传递整个行周围的桌子)
How do you create DataRow instances that aren't tied to any particular DataTable instance?
(EDIT: I know you can create DataRows using the DataTable.NewRow() method, but the problem is that I can't seem to disconnect the row from its parent table so I can pass the individual row around without having to pass the entire table around)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试的一件事是立即删除它:
这会将其放入 Detached 的 DataRowState 中,这听起来就像您想要的那样。我不确定你想从更大的角度实现什么目标,所以这可能没有帮助。
One thing you could try is deleting it immediately:
That will put it in a
DataRowState
of Detached, which sounds like what you want. I'm not sure what you're trying to achieve in terms of a bigger picture though, so this may not help.我宁愿只复制 DataRow 的内容。您可以通过以下方式实现这一目标:
我认为这将是一个更好的方法,而不是尝试为缺乏复制功能找到解决方法。
I rather would only copy the content of the DataRow. You can achive that with:
I think that would be a better approch, than trying to get a workaround for the lacking copy functionality.