Note that there are some explanatory texts on larger screens.

plurals
  1. POwpf c# static combobox selection needs to update second combobox that makes a DB call
    text
    copied!<p>I'm new to WPF, using DevExpress MVVM, I have a static combobox that when the user selects a day, I want to update the second combobox by passing an int day and making a DB call to refresh that combo box with routes based off that day. Here's what I have:</p> <p> --> </p> <pre><code> &lt;Label Content="Route:" Grid.Column="2" Grid.Row="1" Height="28" HorizontalAlignment="Left" Margin="9,60,0,0" Name="lblRoute" VerticalAlignment="Top" /&gt; &lt;ComboBox Grid.Column="2" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="127,65,0,0" Name="cboRoute" VerticalAlignment="Top" Width="120" DataContext="{Binding}" ItemsSource="{Binding Path=RouteList}" DisplayMemberPath="{Binding RouteName}" SelectedValue="{Binding RouteID}" Grid.ColumnSpan="2" IsSynchronizedWithCurrentItem="true"/&gt; </code></pre> <p>ViewModel:</p> <pre><code> public ObservableCollection&lt;RouteTest&gt; BindRouteComboBox2(int day) { mgr = new SRMSRailManagerBLL(); mgr.OpenConnection(ConfigurationManager.ConnectionStrings["SRMSSqlProvider"].ConnectionString); //might not want to pass dataset _routeDS = mgr.getRoutesForCombo(day); _routeDV = _routeDS.Tables[0].DefaultView; //cboRoute.ItemsSource = ds.Tables[0].DefaultView; //cboRoute.DisplayMemberPath = ds.Tables[0].Columns["RouteName"].ToString(); //cboRoute.SelectedValuePath = ds.Tables[0].Columns["RouteID"].ToString(); _routeList = new ObservableCollection&lt;RouteTest&gt;(); foreach (DataRow row in _routeDV.Table.Rows) { RouteTest r = new RouteTest(Convert.ToInt32(row.ItemArray[0]), row.ItemArray[1].ToString()); _routeList.Add(r); } mgr.CloseConnection(); return _routeList; </code></pre> <p>When I click my first combobox, I get the 'Monday' populated in my _SelectionChanged(), what I want is the Tag value of '1', so that I can pass to my BindRouteComboBox(day) procedure to update the second combo box to only show routes for day 1, instead of every route in my DB table. This should be simple and I've gotta be missing something simple here.</p> <p>Thanks,</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload