Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding Combo to data

Status
Not open for further replies.

BrianB

Programmer
Oct 2, 2000
186
US
Hi folks,

I am trying to bind a single combo box to a dataview derived from a table of US and Canadian states and Provinces. Column 0 is the abbreviation ('NC') and Column 1 is the name ('North Carolina'). I want the combo to show state names and store state abbreviations.

When I set the combo's DisplayMember to be the StateAbbreviation and the ValueMember to the StateAbbreviation, it works, giving me a list of abbreviations.

When I set the DisplayMember to the StateAbbreviation and the ValueMember to the StateName, I get a blank combo. When I set both to the StateName, I also get a blank combo. What is going on here?


Here's the code:
dvwData = New DataView(dstData.Tables(0))
ComboBox1.DataSource = dvwData
ComboBox1.DisplayMember = ("StateName")
ComboBox1.ValueMember = ("StateAbbreviation")
ComboBox1.Refresh()


Any suggestions are appreciated.

Brian

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top