Solved

cannot create a child list for field

Posted on 2006-07-21
2
293 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 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