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
Solved

cannot create a child list for field

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 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