Solved

cannot create a child list for field

Posted on 2006-07-21
2
290 Views
Last Modified: 2012-06-22
Hi, Experts,
I have 3 combo boxes that I want to bind to data sources. First one works fine, but the other two have troubles.

The second one’s data only has one column. If I tried to assign the DisplayMember and ValueMember, run-time error says cannot bind to new value member. I commented out the ValueMember part, and the data shows up. However, without the ValueMember, I have hard time to retrieve the selected item/text/value.

The third one causes “Cannot create a child list for field xxx” error. The box shows system.data.dataRowView. No matter how I load my dataset (same ds but different table, or its own ds), the error is the same.

Here is one variation of my code:

Dim dsOptions As DataSet
            dsOptions = SqlHelper.ExecuteDataset(cn_str_QWright_Dev, CommandType.StoredProcedure, "CT_getCSR")
            dsOptions.Tables(0).TableName = "CSR"
            cboCSR.DataSource = dsOptions.Tables("CSR")
            cboCSR.DisplayMember = "CSR"
            cboCSR.ValueMember = "EmployeeID"

            dsOptions.Tables.Add(SqlHelper.ExecuteDataset(cn_str_QWright_Dev, CommandType.StoredProcedure, "CT_getRegions").Tables(0).Copy)
            dsOptions.Tables(1).TableName = "Region"

            cboRegion.DataSource = dsOptions.Tables("Region")
            cboRegion.DisplayMember = "Regions"
            'cboRegion.ValueMember = "regions" 'this one cause error it is the same fld

            Dim dsOptions2 As DataSet
            dsOptions2 = SqlHelper.ExecuteDataset(cn_str_QWright_Dev, CommandType.StoredProcedure, "CT_getCLGTypes")
            dsOptions2.Tables(0).TableName = "CLGType"

            cboType.DataSource = dsOptions2.Tables("CLGType")
            cboType.DisplayMember = "CLGType.TypeName"
            cboType.ValueMember = "CLGType.TypeID" 'err: cannot create a child list for field CLGType




0
Comment
Question by:ommer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 250 total points
ID: 17154540
On the second problem, I think the syntax is wrong.  I'm assuming that the DataTable is CLGType, which you've already set in cboType.DataSource.  In that case, you just want a column name within that table for yur display member and value member.  What the complier will be seeing is CLGType.CLGType.TypeID.  If my assumption about what is a table and what is a column is right, you should change this

            cboType.DisplayMember = "CLGType.TypeName"
            cboType.ValueMember = "CLGType.TypeID" 'err: cannot create a child list for field CLGType

to this

            cboType.DisplayMember = "TypeName"
            cboType.ValueMember = "TypeID" 'err: cannot create a child list for field CLGType

I say "if my assumption ... is right" because, if it is, I would have expected an error on the first of those two lines, not just the second.

On the first problem, I can't see why it would error.  But there's something peculiar about the code that precedes it.  This line

            dsOptions.Tables.Add(SqlHelper.ExecuteDataset(cn_str_QWright_Dev, CommandType.StoredProcedure, "CT_getRegions").Tables(0).Copy)

looks to me like it would not even compile.  There's one more closing bracket than there is opening ones.  But even if it did compile, I'm not sure what it is supposed to be doing.  Unless it's something to do with that, then the only difference I can see is "regions" [lower-case r] instead of "Regions" [capital R], but I've never come across that mattering before.  In principle, though, and I've just tested it, there is no reason why the same single column in a one column datatable should not be used as both the DisplayMember and the ValueMember.

Roger
0
 

Author Comment

by:ommer
ID: 17154858
Roger,

Thank you for your reply.
It turned out to be the Capital R vs r in "Regions"
Also, TypeID is TypeId in stored proc.

Wow!

By the way, on the unusual syntax, I tried to use one dataset with 2 data tables generated by two sp calls for the cboCSR and cboRegion. I got help from experts here, and it works fine.

Thanks a lot!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question