ComboBox Question

  • Thread starter Thread starter Doug Bell
  • Start date Start date
D

Doug Bell

Hi,
I have a problem with a ComboBox bound to a DataView.
The ComboBox shows the correct number of rows but instead of the data, each
row shows "System.Data.DataRowView"

Can someone explain how to fix this and why it is happening?

The Form's Class has:
Imports DataAccessLayer
'Class that retrieves data as a DataSet

I have the following code in the forms Load Event:


Dim dvFac AS DataView
dvFac = dsPOs.Tables("Facs").DefaultView 'Creates a dataview based on
'Facs' Table
dvFac.Sort = "Facility ASC" 'Sorts Facs by field 'Facility'
ComboFacility.DropDownStyle = Windows.Forms.ComboBoxStyle.DropDown
'Sets ComboBox Style
ComboFacility.DataSource = dvFac 'Binds ComboBox to dataView
ComboFacility.Text = Facility 'retrieves current set facility from XML Doc

Thanks

Doug
 
Doug,

I like those easy ones, you have not set the combobox displaymember to the
column (you can extra set with a datasource as well the valuemember)

I hope this helps?

Cor
 
Hi Doug

You need to set the DisplayMember property to the name of the column that
you want to display. You may also want to set the ValueMember property as
well.

HTH

Nigel
 
Hi Cor,

Sorry, I forgot to type that line in my question.

I do have:
ComboFacility.DataSource = dvFac 'Binds ComboBox to dataView
ComboFacility.DisplayMember = "Facility"

Also I have verified that data is correct in the DataView by binding it to a
DataGrid. The DataGrid shows values correctly; '20', '25', '70', etc.

There is only one column in the Table; "Facility".

Sorry it was not so simple.

Doug
 
Hi Nigel,

Thanks, I forgot to re-type the line showing the setting of the
DisplayMember.
(Note my reply to Cor's post)
I did try to set the ValueMember at one point
ComboBoxValueMember = "Facility" 'same field as DisplayMember

but it kept causing an error which I thought was a bit strange???

Doug
 
Dough,

And yet I ask this: are you sure the upercase "F" in "Facility" is the same
as in the select?

Cor
 
Cor,
Yes, I even copied and pasted to check.
Although in the DataGrid it does return the Header as "FACILITY"

Doug
 
Doug,
Yes, I even copied and pasted to check.
Although in the DataGrid it does return the Header as "FACILITY"

And did you try that as well, because AFAIK is this part case sentitive.

Cor
 
Cor,

OK Can you explain that to me.

My DataSet is based on SQL string

strSQL = "SELECT MFFACL AS Facility " & _
"FROM BPCSFPF.ZMF WHERE MFFACL Between '00' And '97'

DataView Sort is working on:
dvFac.Sort = "Facility ASC" 'Sorts Facs by field 'Facility'

But DisplayMember needs "FACILITY"
Where did the uppercase conversion come from??

And what do you mean by "because AFAIK is this part case sentitive"
What is AFAIK?

Thank you for help but I don't understand where the problem comes from.
 
Doug Bell"
But DisplayMember needs "FACILITY"
Where did the uppercase conversion come from??

I do not know that either
What is AFAIK? As Far As I Know

Thank you for help but I don't understand where the problem comes from.

Me either however I will not spent time with this, to be sure you can always
use datatable.columns(0).name next time in this case

Cor
 
Thanks for your help

Cor Ligthert said:
Doug Bell"


I do not know that either


Me either however I will not spent time with this, to be sure you can always
use datatable.columns(0).name next time in this case

Cor
 
Aagh - propagation delays, when I posted, I didn't see any of the dialog
between you and Cor!

Nigel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top