Search code examples
vb.netdatagridviewdatabound

vb.net datagridview removing link to dataset


I load data from an XML to a dataset then I use the dataset to populate my datagridview. By doing that my DGV is getting bound to the dataset. Now I am getting the following error: 'RowCount property cannot be set on a data-bound DataGridView control.'

is there anyway to make my DGV "unbound" again to prevent these errors? or is there another way to fix this?


Solution

  • Thanks for the help jmcilhinney, here the solution I ended up using

    Do While i < Dataset.Tables("table1").Rows.Count
                If i = DGV.RowCount Then
                    DGV.Rows.Add()
                End If
                c = 0
                Do While c < Dataset.Tables("table1").Columns.Count
                    DGV.Rows(i).Cells(c).Value = Dataset.Tables("table1").Rows(i).Item(c)
                    c = c + 1
                Loop
                i = i + 1
            Loop