Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox & DataView.RowFilter

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
I have a vb.net VS 2003 WinForms App with a combobox on a form that is a salesman selection coded as follows.
Code:
dsSalesman = SelectSalesman("ALL")
SalesmanView = New DataView(dsSalesman.Tables(0))

cboSalesman.DisplayMember = "SalesmanText"
cboSalesman.ValueMember = "Salesman"
cboSalesman.DataBindings.Add("SelectedValue", dsOrders, "Order.Salesman")
cboSalesman.DataSource = SalesmanView

SalesmanView.RowFilter = ""
I set the RowFilter to an empty string because initially I want all salesman to show up in the combobox as the user moves through the records. These records are from more than one company, and each company has there own salesman. When the user decides to edit the record by clicking a button, I am trying to restrict the salesman in the combobox to be only the valid ones for that company. I have a sub that does the following.
Code:
SalesmanView.RowFilter = "SalesmanCompany = " + Company.ToString
SalesmanCompany is an integer column in the salesman table and Company is the integer column form the orders table that is passed in. The problem is when the user clicks the button, the value of the combobox changes from the original value to another salesman. The list has the proper values in it according to the company, but it displays the wrong value. I have tried refreshing the combobox, and resetting the datasource with no luck. I know this is probably something very simple, but I can't seem to get it to work properly.


Auguy
Northwest Ohio
 
I got it to work by clearing the bindings and datasource. Then resetting everything for the cboSalesman whenever the filter changes.

Auguy
Northwest Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top