473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Binding combobox with datareader???

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 ...
Nov 17 '05 #1
4 12733
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

Annie wrote:
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 ...


Nov 17 '05 #2
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
"mphacker" <mp******@sitedevelopers.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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

Annie wrote:
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 ...

Nov 17 '05 #3
Use a DataTable. Data grids work a little diff for win apps.

--

Derek Davis
dd******@gmail.com

"Annie" <my**************@gmail.com> wrote in message
news:43******@dnews.tpgi.com.au...
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 ...

Nov 17 '05 #4
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.

--

Derek Davis
dd******@gmail.com

"carion1" <dd******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Use a DataTable. Data grids work a little diff for win apps.

--

Derek Davis
dd******@gmail.com

"Annie" <my**************@gmail.com> wrote in message
news:43******@dnews.tpgi.com.au...
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 ...


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Omar | last post by:
When I try to databind my comboBox (specifically field "emplcode") to a filled dataset , the contents of the comboBox displays a bunch of "System.Data.DataRowView". I assume the amount of times...
4
by: Brian Conway | last post by:
I need some help on binding a datareader to a dropdown box. I have included the code for the dropdown below. It builds with no errors, but returns no results. Any help would be appreciated. ...
5
by: Poonam | last post by:
I have a department table with DeptID and DeptName. I am trying to fill my combobox with DeptName. Here is my code but it does not work? Can someone help me? Dim pxy As New Channel1.Channel...
0
by: Michael C# | last post by:
I have found a few samples of using a combobox in a Datagrid on the Web (Windows Forms). While these examples work well for what they do, I need more functionality, and I'd like some advice on the...
0
by: Richard | last post by:
I have a combobox that I use to display the advertising medium that attracted a client. On the Client's table is the foreign key AdvertisingMedium, and the combobox successfully reads the data...
3
by: Steve King | last post by:
I'm attempting to bind a combobox to store the values in tblProblems.VersionID and display the Version value from the tblVersions. The VersionID field is a foreign key to the ID in tblVersions. ...
1
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I have a ComboBox named comboBoxSelChannel. I declared a structure named MySturct. public struct MyStruct { public int Index; public string Name;
1
by: Shimon Sim | last post by:
I can't figure out how to bind ComboBox inside of ListView or ListBox. How do I set ComboBox.ItemsSource property? I don't see the way to do it in code and not in XAML. I have Collection that is...
2
by: Aads | last post by:
Hi all, Could anyone tell me what's the advantage of binding a structure to a combobox over a simple array considering that a structure contains a parameterized constructor(of course) & then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.