Solved

cannot create a child list for field

Posted on 2006-07-21
2
278 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
2 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 250 total points
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now