473,398 Members | 2,404 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,398 software developers and data experts.

Problem binding combobox to dataset

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
dsDepts = pxy.getDepartments()
cmbDept.DisplayMember = "DeptName"
cmbDept.ValueMember = "DeptID"
cmbDept.DataSource = dsDepts.Tables("Department")

This does not give any error but it does not fill my combobox. It
remains empty.

if I give the following:
cmbDept.Datasource = dsdepts

it fills the combobox with the following:
System.Data.DataViewManagerListItemTypeDescriptor

Also do I have to add the databindings property or not?

getdepartments webmethod simply returns the dataset.

the following does not work.
cmbDept.DataSource = dsDepts.Tables(0)
It's urgent. I need help.
Poonam

Nov 21 '05 #1
5 6667
Here is the code I use to do something similar. You need to bind both the
DisplayMember and ValueMember to one column, and I use the Tag property to
store my ID Field.

Try something like this.
cmbDept.DataBindings.Add(New System.Windows.Forms.Binding("Tag", dsDepts,
"tablename.DeptID"))cmbDept.DataSource =DsDepts
cmbDept.DisplayMember = "tablename.DeptName"
cmbDept.ValueMember = "tablename.DeptName"

"Poonam" <po***********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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
dsDepts = pxy.getDepartments()
cmbDept.DisplayMember = "DeptName"
cmbDept.ValueMember = "DeptID"
cmbDept.DataSource = dsDepts.Tables("Department")

This does not give any error but it does not fill my combobox. It
remains empty.

if I give the following:
cmbDept.Datasource = dsdepts

it fills the combobox with the following:
System.Data.DataViewManagerListItemTypeDescriptor

Also do I have to add the databindings property or not?

getdepartments webmethod simply returns the dataset.

the following does not work.
cmbDept.DataSource = dsDepts.Tables(0)
It's urgent. I need help.
Poonam

Nov 21 '05 #2
You have to run the cmbDept.Refresh after assigning the DisplayMember,
ValueMember and DataSource.

Hope this helps,
Brian Swanson

"Poonam" <po***********@gmail.com> wrote in message
news:po***********@gmail.com:
Dim pxy As New Channel1.Channel
dsDepts = pxy.getDepartments()
cmbDept.DisplayMember = "DeptName"
cmbDept.ValueMember = "DeptID"
cmbDept.DataSource = dsDepts.Tables("Department")

This does not give any error but it does not fill my combobox. It
remains empty.


Nov 21 '05 #3
cmbDept.DisplayMember = "Department.DeptName"
cmbDept.ValueMember = "Department.DeptName"
cmbDept.DataSource = dsDepts
cmbDept.DataBindings.Add(New System.Windows.Forms.Binding("Tag",
dsDepts, "Department.DeptID"))
An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll

Additional information: Cannot create a child list for field
Department.

It does not work. I do not understand what the problem is.

But thanks Kevin.

Poonam

Nov 21 '05 #4
Did you fill the dataset?
DataAdapterObject.Fill(DataSetObject)

Hope this helps...
Raj Prakash
"Poonam" <po***********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
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
dsDepts = pxy.getDepartments()
cmbDept.DisplayMember = "DeptName"
cmbDept.ValueMember = "DeptID"
cmbDept.DataSource = dsDepts.Tables("Department")

This does not give any error but it does not fill my combobox. It
remains empty.

if I give the following:
cmbDept.Datasource = dsdepts

it fills the combobox with the following:
System.Data.DataViewManagerListItemTypeDescriptor

Also do I have to add the databindings property or not?

getdepartments webmethod simply returns the dataset.

the following does not work.
cmbDept.DataSource = dsDepts.Tables(0)
It's urgent. I need help.
Poonam

Nov 21 '05 #5
I did that. But still not getting there. I get errors in the display
member and value member properties.
Thanks,
Poonam
Dim pxy As New Channel1.Channel
dsDepts = pxy.getDepartments()
cmbDept.DisplayMember = "DeptName"
cmbDept.ValueMember = "DeptID"
cmbDept.DataSource = dsDepts.Tables("Department")

getDepartments webmethod is as follows:

<WebMethod()> _
Public Function getDepartments() As DataSet
Dim Sql1 As String = "Select * from Department"
Dim ds As DataSet = objDb.getdataset(Sql1)
Return ds
End Function

Public Function getDataSet(ByVal SqlSelect As String) As DataSet
Dim myDataAdapter As New OleDbDataAdapter(SqlSelect,
myConnection)
Dim myDataSet As New DataSet
myDataAdapter.Fill(myDataSet)
ds = myDataSet
Return myDataSet
End Function

Nov 21 '05 #6

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...
13
by: Paul Slavin | last post by:
I have a textbox bound to a dataview, when I update the text in the textbox no changes take place in the underlying dataset. Why is this?? any answers appreciated, as to due to the underlying...
3
by: Russ | last post by:
I have a subroutine that I call to bind a dataset to a combobox. It works sometimes. See the code below.. 1 Private Sub BindDropDownToDataSet( _ 2 ByRef control As...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
0
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue...
0
by: Tommaso Caldarola | last post by:
2.0 - No Typed DataSet. My custom object implements all the needed interface (IList, IBindingList, ITypedList) in order to manage complex binding. With DataGridView control I have no problem. ...
3
by: Peter | last post by:
OK, so in addition to the problem I mentioned before (c.f. "Data Binding to Textbox"), I realized that my comboboxes are not really bound to the internal data set. They are just set to manually...
1
by: Robert Dufour | last post by:
I have a table of addresses and it contains a CountryId which points to a table of countries. The datatstructure of the Countries Lookup tables is actually created from three tables - a...
1
by: Jim | last post by:
Hi, Trying to implement databinding. I've a dataset with a table, a windows form with typical controls: combobox, datetimepicker, textbox . . . I use what I think is a normal method to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.