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

Populate dropdown list with parameterized stored procedure.

TonFrere
P: 14
Hello,
I'm building a windows form application in Visual C# using VS 2005. On my form I need to populate a combobox with Invoices# linked to the current reccord's Order# value. This means that:
- The combobox should repopulate if the user changes the value of Order#.
- The combobox should repopulate if the user moves through records (using the binding navigator.

My problem is that whenever I repopulate the combobox, it's value is reset to the top value of the list. For example, the order# 366 populates the dropdown list with values 566, 567, 568. If a user selects Invoice# 567 and save record, it will be reseted to 566 as soon as he move to the next record and go back to this one.

How it's done:
So far, I created a stored procedure in SQL server 2005 that connects to my oracle server and returns a set of invoice numbers denpending on parameter @OrderNum.

In VS, my dataset has an RMA table adapter (This is the main table, the one the Form is build on and which the bindingnavigator move through). I also have a table adapter called "Invoice" that expects a parameter and which calls the stored procedure.

On my form, I display RMA info including the curent's RMA Order# and a combobox to select one of the Invoice# linked to this Order#. The combobox is linked to the InvoiceBindingSource, has Invoice as DisplayMember and ValueMember and the current reccord's Invoice# as SelectedValue

Finally, on the OnTextChange event of the Order# text box, I have the following code:

InvoiceNum_ComboBox.DataSource = InvoiceTableAdapter.GetInvoices(OrderNum_TextBox.T ext);

Very simple to code but, the results are not as expected.

I searched MSDN but I can't find a recommended way to code this.

Any advice?
Nov 27 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.