I have two comboboxes, both with binding sources attached which are pre-populated with data from a SQL server;
private void SetLocationAreaBindingSource()
{
cboLocationArea.DisplayMember = "name";
cboLocationArea.ValueMember = "areaID";
DynamicParameters parameters = new DynamicParameters();
parameters.Add("@LocationType", 4);
locationAreaBindingSource.DataSource = db.Query<LocationArea>("LocationAreas_GetWhereType", parameters, commandType: CommandType.StoredProcedure);
}
private void SetLocationBayBindingSource()
{
cboLocationBay.DisplayMember = "name";
cboLocationBay.ValueMember = "bayID";
locationBayBindingSource.DataSource = db.Query<LocationBay>("SELECT * FROM [LocationBays] ORDER BY [name] ASC", commandType: CommandType.Text);
}
When the user selects a value in the first combobox (cboLoacationArea) I need to filter the results down in cboLocationBay to only show the results related to that area;
private void cboLocationArea_SelectedIndexChanged(object sender, EventArgs e)
{
locationBayBindingSource.Filter = "[locationAreaID] = " + cboLocationArea.SelectedValue;
cboLocationBay.Refresh();
}
however the above code doesnt seem to work and just shows the full list. How can I achieve this?