Referring to Columns by Name with Bound dgv
Posted on 2010-09-01
If I bind a table to a dgv using the following ("manual") process, I can reference each column by its' assigned name in the table (dgv.rows(i).cells("Address").value).
str_Select = "SELECT * " & _
Dim con_SE As New OleDbConnection(str_OleDB_Connection_Provider_MDB)
cmd = New OleDb.OleDbCommand(str_Select, con_SE)
da_Groups = New OleDbDataAdapter(cmd)
dgv_Groups.DataSource = da_Groups
dgv_Groups_Filter.Table = dt_Groups
Howver, if I bind a table to a dgv using a typed Dataset (using "Data Sources" in Visual Studio and dragging a table onto a form), I cannot reference each column by its' assigned name - I get "Value cannot be null. Parameter name: dataGridViewColumn". If I reference the column by it's position (...cells(1).value), everybody's happy.
Why can't I reference a column by its' name when I bind with typed Dataset, but I can when I "manually" bind?
Thank you in advance for your help!