DataGrid Issues

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having two issues with my datagrid. First, my column headers are not displaying.

Second, the grid runs and displays correctly (except the headers) the first time. When the grid runs for the second time I get an error

An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dl

Additional information: Cannot create a child list for field Additional

The code is below. Does anyone see the error

Thanks in Advance
Elen

strsql = "Select add_desc, add_cost from Additional where expense_id = " & TextBox3.Text & " order by add_id desc
Debug.Write(strsql

' Create data adapter objec
Dim daGrid As OleDbDataAdapter = New OleDbDataAdapter(strsql, Expenses.conn

' Create a dataset object and fill with data using data adapter's Fill metho
Dim dsGrid As DataSet = New DataSe
daGrid.Fill(dsGrid, "Additional"
Dim dvGrid As DataView = dsGrid.Tables("Additional").DefaultVie
DataGrid1.DataMember = "Additional
DataGrid1.DataSource = dvGri

Dim dgts As DataGridTableStyle = New DataGridTableStyl
dgts.MappingName = "Additional

dgts.GridColumnStyles.Add(New DataGridTextBoxColumn
dgts.GridColumnStyles.Item(0).MappingName = "add_desc
dgts.GridColumnStyles.Item(0).HeaderText = "Description
dgts.GridColumnStyles.Item(0).Width = 30
dgts.GridColumnStyles.Add(New DataGridTextBoxColumn
dgts.GridColumnStyles.Item(1).MappingName = "add_cost
dgts.GridColumnStyles.Item(1).HeaderText = "Cost
dgts.GridColumnStyles.Item(1).Width = 200
 
One problem solved! I can't believe I forgot to add the style.

Anyway, the second error is still coming up.

Any Ideas

Thanks
Elen


----- Ken Tucker [MVP] wrote: ----

Hi

I dont see where you add the datagrid table style to the datagrid

Ke
--------------------------
 
Hi,

Try deleting this line. You shouldn't need to set the datamember if
you are binding to a dataview.

DataGrid1.DataMember = "Additional"

Ken
 
YAY! Thank you, Thank you, Thank you!!

Finally
Elen


----- Ken Tucker [MVP] wrote: ----

Hi

Try deleting this line. You shouldn't need to set the datamember if
you are binding to a dataview

DataGrid1.DataMember = "Additional

Ke
 
Back
Top