ERROR: Cannot create child list

ERROR: Cannot create child list

Post by Jeff Tolma » Thu, 22 Sep 2005 11:57:08


his is a multi-part message in MIME format.


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 = SalesOrder.GetStagingItems(stagingDate)
If Not IsNothing(dsSOItems) AndAlso _
dsSOItems.Tables.Count = 1 AndAlso _
dsSOItems.Tables(0).Rows.Count > 0 Then

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

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

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

Dim tempDS As DataSet
tempDS = StagingLocation.GetStagedSOs()
Dim myDT As DataTable = 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.

Any help is greatly appreciated!

Thanks!

Jeff Tolman
E&M Electric - Serra Integration Group
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2722" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>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?</DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>A snippet from my code is as follows:</DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>       
dsSOItems =
SalesOrder.GetStagingItems(stagingDate)<BR>       
If Not IsNothing(dsSOItems) AndAlso
_<BR>          
dsSOItems.Tables.Count = 1 AndAlso
_<BR>          
dsSOItems.Tables(0).Rows.Count > 0 Then</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>            Dim dt
As DataTable =
GetStagingPicks()<BR>           
dgPicks.SetDataBinding(dt, dt.TableName)       
<-----THIS ONE WORKS!</FONT></DIV>
<DIV><FONT face=Arial size=2><
 
 
 

ERROR: Cannot create child list

Post by Bart Mermu » Thu, 22 Sep 2005 18:02:02

Hi,






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,"")


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


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

dgDetail.SetDataBinding(myDT, "")



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





Jeff Tolman
E&M Electric - Serra Integration Group

 
 
 

ERROR: Cannot create child list

Post by Jeff Tolma » Fri, 23 Sep 2005 08:39:24

Thanks Bart! That works---wish I had tried that in the first place! duh!