Hi I’m trying to copy one row from DataTable to another, I looked almost everywhere and I can’t find a reason why this is happening, I’m using ImportRow and still the New DataTable is empty.
Here’s one of the answers similar I found and It’s still not working!:
Dim newTable As New DataTable
Dim dsFrom As New DataTable
For Each DBShoes In list
Dim iShoeID As Integer
iShoeID = DBShoes.sShoes_ID
dsFrom = DBShoes.GetFullShoeDetails(iShoeID)
For Each dr As DataRow In dsFrom.Rows
newTable.Rows.Add(dr.ItemArray)
Next
Next
GridView1.DataSource = newTable
GridView1.DataBind()
Error: Input array is longer than the number of columns in this table.
Here’s the Import that doesn’t crash but nothing is added in the DataTable:
Dim newTable As New DataTable
Dim dsFrom As New DataTable
For Each DBShoes In list
Dim iShoeID As Integer
iShoeID = DBShoes.sShoes_ID
dsFrom = DBShoes.GetFullShoeDetails(iShoeID)
For Each dr As DataRow In dsFrom.Rows
newTable.ImportRow(dr)
Next
Next
GridView1.DataSource = newTable
GridView1.DataBind()
Else
Thanks
I have created a form with two DataGridView controls on it.
Here is the code of form: