Solved

cannot create a child list for field

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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