ComboBox Value

  • Thread starter Thread starter Dianna K
  • Start date Start date
D

Dianna K

Hi,

I am trying to set the value of the a combobox with a
field from a dataset. It will not set.

Me.cboTypeDesc.Text = DsTitle.Tables("Title").Rows(0).Item
("genre_description")

or

index = cboTypeDesc.FindStringExact(DsTitle.Tables
("Title").Rows(0).Item("genre_description"))
Me.cboGenre.SelectedIndex = index

Is there something wrong with the above? The combo box is
being filled via a datasource (displayMember, valueMember).

Any help would be great,
Thanks, Dianna
 
Hi

Try using the SelectedItem property, although the code you write should be
working in my opinion.

You could set some breakpoints to check if the
DsTitle.Tables("Title").Rows(0).Item("genre_description") has an expected
value that can be found in the cboTypeDesc.DataSource.

Jan

__________________________________________
Read my weblog: http://weblogs.asp.net/jan
 
I suspect the problem is in the tables value

combobox.text is just setting a text according to the
input (doesn't even check if the item is in the
combobox). So either the assigned value was "" (empty
string)
or your code didn't execute at all
 
Thank you for your help. It seems I was missing
the 'ToString' on my field value

DsTitle.Tables("Title").Rows(0).Item
("genre_description").ToString

I knew it was something ridiculous.

Dianna
 
Thank you for your help. It seems I was missing
the 'ToString' on my field value

DsTitle.Tables("Title").Rows(0).Item
("genre_description").ToString

I knew it was something ridiculous.

Dianna
 

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