By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,644 Members | 2,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,644 IT Pros & Developers. It's quick & easy.

Combobox binding

P: n/a
Hello,
I have 6 comboboxes, that I thought I could bind to the same datasource, and
have them display different 'selectedvalue's', but apparently I can't...

My code is as follows:

dim drv as datarowview = me.listbox1.selecteditem
dim dtbDL as datatable = _dataset1.Tables(0)
dim dtvDL as new dataview(dtbDL)
dtvDL.RowFilter = "STR_ONE" = 'Matching Text'"

'Combobox 1
Me.cbo1.datasource = dtvDL
me.cbo1.ValueMember = "STR_DISPLAY_VALUE"
me.cbo1.DisplayMember = "STR_DISPLAY_VALUE"
me.cbo1.SelectedValue = drv("ITEM_1_FROM_DATABASE").ToString

'Combobox 2
Me.cbo2.datasource = dtvDL
me.cbo2.ValueMember = "STR_DISPLAY_VALUE"
me.cbo2.DisplayMember = "STR_DISPLAY_VALUE"
me.cbo2.SelectedValue = drv("ITEM_2_FROM_DATABASE").ToString

Obviously I'm not able to do this...whatever the value is in
ITEM_2_FROM_THE_DATABASE is displayed in both.

I want all 6 comboboxes to display the same drop downlist of (76) values,
but to display the corresponding value in the database for each item.

Make sense??
Do I need to declare a new dataview each time? and/or datatable??

Thanks!
amber

Nov 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Amber,

When I understand you well, than you can by creating for every combobox its
own dataview.

I hope this helps,

Cor

"amber" <am***@discussions.microsoft.com>
Hello,
I have 6 comboboxes, that I thought I could bind to the same datasource,
and
have them display different 'selectedvalue's', but apparently I can't...

My code is as follows:

dim drv as datarowview = me.listbox1.selecteditem
dim dtbDL as datatable = _dataset1.Tables(0)
dim dtvDL as new dataview(dtbDL)
dtvDL.RowFilter = "STR_ONE" = 'Matching Text'"

'Combobox 1
Me.cbo1.datasource = dtvDL
me.cbo1.ValueMember = "STR_DISPLAY_VALUE"
me.cbo1.DisplayMember = "STR_DISPLAY_VALUE"
me.cbo1.SelectedValue = drv("ITEM_1_FROM_DATABASE").ToString

'Combobox 2
Me.cbo2.datasource = dtvDL
me.cbo2.ValueMember = "STR_DISPLAY_VALUE"
me.cbo2.DisplayMember = "STR_DISPLAY_VALUE"
me.cbo2.SelectedValue = drv("ITEM_2_FROM_DATABASE").ToString

Obviously I'm not able to do this...whatever the value is in
ITEM_2_FROM_THE_DATABASE is displayed in both.

I want all 6 comboboxes to display the same drop downlist of (76) values,
but to display the corresponding value in the database for each item.

Make sense??
Do I need to declare a new dataview each time? and/or datatable??

Thanks!
amber

Nov 22 '05 #2

P: n/a
do what you want.

:-)
Nov 22 '05 #3

P: n/a
I'm not sure if this will help, but I was reading in Chris Sells 'Windows
Forms Binding in C#, footnote, page 482', that the data source is bound to
each combobox and is managed by a common Binding manager which in turn is
part of a Binding Context. The Binding amager keeps all comboboxes
synchronized to the same row in the database. However, if each combobox has
a different Binding context, hence a diferent Binding Manager, then the combo
boxes can show different rows from the same data source.

"amber" wrote:
Hello,
I have 6 comboboxes, that I thought I could bind to the same datasource, and
have them display different 'selectedvalue's', but apparently I can't...

My code is as follows:

dim drv as datarowview = me.listbox1.selecteditem
dim dtbDL as datatable = _dataset1.Tables(0)
dim dtvDL as new dataview(dtbDL)
dtvDL.RowFilter = "STR_ONE" = 'Matching Text'"

'Combobox 1
Me.cbo1.datasource = dtvDL
me.cbo1.ValueMember = "STR_DISPLAY_VALUE"
me.cbo1.DisplayMember = "STR_DISPLAY_VALUE"
me.cbo1.SelectedValue = drv("ITEM_1_FROM_DATABASE").ToString

'Combobox 2
Me.cbo2.datasource = dtvDL
me.cbo2.ValueMember = "STR_DISPLAY_VALUE"
me.cbo2.DisplayMember = "STR_DISPLAY_VALUE"
me.cbo2.SelectedValue = drv("ITEM_2_FROM_DATABASE").ToString

Obviously I'm not able to do this...whatever the value is in
ITEM_2_FROM_THE_DATABASE is displayed in both.

I want all 6 comboboxes to display the same drop downlist of (76) values,
but to display the corresponding value in the database for each item.

Make sense??
Do I need to declare a new dataview each time? and/or datatable??

Thanks!
amber

Nov 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.