Groups | Blog | Home
all groups > dotnet windows forms databinding > september 2005 >

dotnet windows forms databinding : ERROR: Cannot create child list



Jeff Tolman
9/20/2005 7:57:08 PM
I am coming across a very strange problem where can't seem to bind my =
datatable to my datagrid. I have two datagrids, where the first is =
having no problem binding to a datatable. However, my second datagrid =
keeps getting a "Cannot create child list for field 'Table'". Does =
anyone know what this error means?

A snippet from my code is as follows:

dsSOItems =3D SalesOrder.GetStagingItems(stagingDate)
If Not IsNothing(dsSOItems) AndAlso _
dsSOItems.Tables.Count =3D 1 AndAlso _
dsSOItems.Tables(0).Rows.Count > 0 Then

Dim dt As DataTable =3D GetStagingPicks()
dgPicks.SetDataBinding(dt, dt.TableName) <-----THIS =
ONE WORKS!

If dt.Rows.Count > 0 Then
'Select the first row
dgPicks.CurrentRowIndex =3D 0
dgPicks.Select(0)
End If

Dim num As Integer =
<-----Just some debugging lines
num =3D dsSOItems.Tables(0).Rows.Count
Dim str As String
str =3D dsSOItems.Tables(0).TableName

Dim tempDS As DataSet
tempDS =3D StagingLocation.GetStagedSOs()
Dim myDT As DataTable =3D tempDS.Tables(0)

dgDetail.SetDataBinding(myDT, myDT.TableName) <-----THIS =
ONE FAILS!
End If

In the second databinding call if I change the datatable to a dataset =
and the datamember parameter to "Table" it will display the data. =
However it will not bind to any display columns that I have setup for =
the datagrid. =20

Any help is greatly appreciated!

Thanks!

Jeff Tolman
Bart Mermuys
9/21/2005 11:02:02 AM
Hi,

[quoted text, click to view]

Well, here it might work because dt.TableName may be an empty string, but it
is wrong. When you bind directly to a DataTable and not to a DataSet then
you have to use an empty string for DataMember :

dgPicks.SetDataBinding(dt,"")

[quoted text, click to view]

Same here, if you bind to a DataTable then specify an empty DataMember:

dgDetail.SetDataBinding(myDT, "")

[quoted text, click to view]

Not sure what you mean here, if you are talking about DataGridTableStyles
and DataGridColumnStyles, then you have to be carefull, because here you
must *always* specify the right TableName for the MappingName of the
DataGridTableStyle:

' first table
Dim gridStyle1 As New DataGridTableStyle
gridStyle1.MappingName = dt.TableName ' could be empty

' second table
Dim gridStyle2 As New DataGridTableStyle
gridStyle2.MappingName = myDT.TableName


HTH,
Greetings



[quoted text, click to view]

Jeff Tolman
E&M Electric - Serra Integration Group

Jeff Tolman
9/21/2005 4:39:24 PM
Thanks Bart! That works---wish I had tried that in the first place! duh!

[quoted text, click to view]

AddThis Social Bookmark Button