Hi,
[quoted text, click to view] >"Jeff Tolman" <jeff.tolman@enm.com> wrote in message
>news:%23%>23mVpglvFHA.1560@TK2MSFTNGP09.phx.gbl...
>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!
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] > 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!
Same here, if you bind to a DataTable then specify an empty DataMember:
dgDetail.SetDataBinding(myDT, "")
[quoted text, click to view] > 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.
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] >Any help is greatly appreciated!
>Thanks!
Jeff Tolman
E&M Electric - Serra Integration Group