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

lookup databinding combobox using stored procedures

P: n/a
I have a lookup table with and ID field and a Description field, and another
table that has its own ID field, the ID field from the lookup table, and
other data.

LookupTable
LookupTable.ID
LookupTable.Description
OtherDataTable
OtherDataTable.ID
OtherDataTable.LookupTableID
OtherDataTable.OtherData

There are stored procedures for SELECT, INSERT, UPDATE, and DELETE that
maniuplate data in the OtherDataTable as well as another set of stored
procedures for the LookupTable.

I need to create a form that shows the details of the OtherDataTable. To
that end I've created a DataSet that contains a DataTable based on the SELECT
stored procedure for the OtherDataTable the DataTable's INSERT, UPDATE, and
DELETE commands have been set to the stored procedures and I can call them
from my code. In the details of the form I would like to use a combo box
that will allow the use to make a selection based upon the list from
LookupTable where the selected item is LookupTable.Description and the
slected value is LookupTable.ID and the LookupTable.ID value is stored in
OtherDataTable.LookupTableID. Of course as the user scrolls through the
OtherDataTable the combo box must display the appropreate selection.
Aug 6 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
What you want to do is load the contents of LookupTable into another
data table or something of that nature, and then bind the drop down list to
that (through the DataBindings and DataSource properties). You also have to
set the ValueMember and DisplayMember properties to indicate which column on
the data table should be displayed, and which one should be used as a value.

Once you do that, you can add a binding to the control which binds your
column to the SelectedValue property. When that property changes (when an
item is selected in the list) it will update your data source, and vice
versa.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"TD is PSP" <TD is PS*@discussions.microsoft.comwrote in message
news:9C**********************************@microsof t.com...
>I have a lookup table with and ID field and a Description field, and
another
table that has its own ID field, the ID field from the lookup table, and
other data.

LookupTable
LookupTable.ID
LookupTable.Description
OtherDataTable
OtherDataTable.ID
OtherDataTable.LookupTableID
OtherDataTable.OtherData

There are stored procedures for SELECT, INSERT, UPDATE, and DELETE that
maniuplate data in the OtherDataTable as well as another set of stored
procedures for the LookupTable.

I need to create a form that shows the details of the OtherDataTable. To
that end I've created a DataSet that contains a DataTable based on the
SELECT
stored procedure for the OtherDataTable the DataTable's INSERT, UPDATE,
and
DELETE commands have been set to the stored procedures and I can call them
from my code. In the details of the form I would like to use a combo box
that will allow the use to make a selection based upon the list from
LookupTable where the selected item is LookupTable.Description and the
slected value is LookupTable.ID and the LookupTable.ID value is stored in
OtherDataTable.LookupTableID. Of course as the user scrolls through the
OtherDataTable the combo box must display the appropreate selection.

Aug 7 '07 #2

P: n/a
So if I understand correctly I would have code similar to the following:

CB.DataSource = LookupTableDataSet
CB.ValueMember = LookupTable.ID
CB.DisplayMember = LookupTable.Description
CB.DataBindings.Add(?)

I'm however unclear on what I should be putting for the DataBindings.Add.
Would you please reply with some code like response. Thanks!

Aug 8 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.