将选定行绑定到新数据行并使用导入行VB.NET

将选定行绑定到新数据行并使用导入行VB.NET,vb.net,datatable,row,datarow,datarowview,Vb.net,Datatable,Row,Datarow,Datarowview,我正在将所选行绑定到需要添加到数据库的新数据行 我正在使用dt.Importrow(newRow)将新数据行添加到数据表中 但是,如果我对此新行进行更改,它也会更改选定的行 代码如下 ''' Dim original_Row As DataRow Dim newRow As DataRow = dt.NewRow original_Row = CType(DataTbale.CurrentRow.DataBoundItem, Data

我正在将所选行绑定到需要添加到数据库的新数据行

我正在使用dt.Importrow(newRow)将新数据行添加到数据表中

但是,如果我对此新行进行更改,它也会更改选定的行

代码如下

'''             Dim original_Row As DataRow
                Dim newRow As DataRow = dt.NewRow   
original_Row = CType(DataTbale.CurrentRow.DataBoundItem, DataRowView).Row 

                newRow = original_Row
newRow(“Name”)=John在此处将值更改为新行

                dt.ImportRow(newRow)'''

我认为您实际上想要做的是为
DataTable
创建一个新行,从当前选定的行复制数据,修改该数据,然后将该行添加到表中

首先,您应该通过
BindingSource
绑定您的
DataTable
,并从中获得选择:

“获取当前行。
Dim currentRow=DirectCast(myBindingSource.Current,DataRowView).Row
'创建新行。
Dim newRow=myDataTable.newRow()
'将现有数据复制到新行。
newRow.ItemArray=currentRow.ItemArray
'编辑数据。
纽罗(“姓名”)=“约翰”
'将新行添加到表中。
myDataTable.Rows.Add(新行)