| re: Problem binding combobox to dataset
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" <poonam.g.buch@gmail.com> wrote in message
news:1109278000.034249.230790@o13g2000cwo.googlegr oups.com...[color=blue]
> 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
>[/color] |