Luis
Luis

Reputation: 31

Combobox Issues System.data.datarowview

I'm working on a GUI and when I'm pulling information from a SQL database, I'm having issues with the results. Instead of the information I've requested, I'm getting the following:

enter image description here

Here is the code i am using:

enter image description here

Upvotes: 1

Views: 101

Answers (1)

sujith karivelil
sujith karivelil

Reputation: 29026

You need to assign the ValueMember and DisplayMember from the collection that you are using to bind the combobox. Here you are fetching only the name both the fields can be "name" suppose you are taking some vehicle_id and name, probably "vehicle_id" will be the ValueMember. So use like this:

cbSelectVehicle.ValueMember="name";
cbSelectVehicle.DisplayMember="name";
cbSelectVehicle.DataSource=dt_vehicle;

DisplayMember is nothing but what we seen in the UI, where as the valueMember is hidden but we can access them through code.

Upvotes: 1

Related Questions