combo box question

jvcoach23

Centurion
Joined
May 22, 2003
Messages
192
Location
Saybrook, IL
I've done combo boxes before.. but can't get this one wired up.

Code:
   Try
            With Me.cbCompany
                .DataSource = wsPerfmon.spPMListing_Company.Tables(0).DefaultView
                .DisplayMember = "vcCompanyName"
                .ValueMember = "intTblPMCompanyId"
            End With
        Catch ex As Exception
            Throw ex
        End Try

it's giving me the "Cast from type 'DataRowView' to type 'Integer' is not valid."

The data coming backup from the function is
intTblPMCompanyId vcCompanyName
1 Home
2 Test1
3 Test

the error comes when i hit the .valuemember. the intTblPMCompanyId row is an integer datatype from Sql server

I'm brining back a dataset from the function.
Hope that is enough to get around this. I'm using the same methods elsewhere in my code and it seems to be working fine.
 
Got it

figured it out.. in case someone else runs into it...

Code:
            With Me.cbCompany
                .DataSource = wsPerfmon.spPMListing_Company.Tables(0).DefaultView
                .DisplayMember = "vcCompanyName"
                .ValueMember = "intTblPMCompanyId"
            End With
needs to be
Code:
            With Me.cbCompany
                .DisplayMember = "vcCompanyName"
                .ValueMember = "intTblPMCompanyId"
                .DataSource = wsPerfmon.spPMListing_Company.Tables(0).DefaultView
            End With

from greg on another list
"well you are setting the ValueMember and DisplayMember (they are used in the databinding) when you call databind before setting these the databind will assume object based databinding (i.e. no value/display memeber)"
 
Back
Top