Binding combobox with datareader???

  • Thread starter Thread starter Annie
  • Start date Start date
A

Annie

hello guys,

I am trying to bind the combobox using a dataread as below: but it doesn't
work??

Do While (reader.Read)

cboTest.DisplayMember = reader.Item("au_lname")

cboTest.ValueMember = reader.Item("au_id")

Loop



what is wrong here?

help please ...
 
You are a bit off on your idea.

You need to set:

cboTest.DataSource=reader
cboTest.DisplayMember="au_lname"
cboTest.ValueMember="au_id"
cboTest.DataBind()

no need to loop :-)

Mike
 
Hello,

I exactly did the same thing ... sorry of course no loop in the first place
.... but then I used looping. Still error :

Error:
Additional information: Complex DataBinding accepts as a data source either
an IList or an IListSource

also i don't have something like:

cboTest.DataBind() ????

TA
 
To be a little more specific, use a Data Table as the datasource. Set the
display and value members to columns in the Data Table and your set.
 
Back
Top