There is two combobox in my WPF app.
<ComboBox x:Name="itemsList" HorizontalAlignment="Left" Margin="10,90.767,0,0" VerticalAlignment="Top" Width="215" IsEditable="True" Height="23"/>
<ComboBox x:Name="pSize" HorizontalAlignment="Left" Margin="230,90.767,0,0" VerticalAlignment="Top" Width="109.538" Height="23" IsEditable="True" />
First combobox fetch items from database with this function which i initialize when app loads
void getAllItems()
{
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT DISTINCT item_name FROM items", conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.ExecuteNonQuery();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
String items = dr.GetString(0);
itemsList.Items.Add(items);
}
conn.Close();
}
I want to bind my second combobox "pSize" with "itemlist". I want to get the value from itemlist and pass to the method which generate items for "pSize" from database according to the parameters.I tried to bind it but not working.