WPF 中combobox 二级 关系怎么搞??
后台代码:
/// <summary>
/// 加载下拉框
/// </summary>
public void LoadCB_name() --------------------------------------------------------------------------->第一个下拉框的加载
{
string strCB_name = "select CompanyName from Company";
using (SqlConnection con = new SqlConnection(sql_conn))
{
con.Open();
SqlCommand cmd = new SqlCommand(strCB_name,con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
this.cb_Name.ItemsSource = dt.AsDataView();
this.cb_Name.DisplayMemberPath = "CompanyName";
}
}
public void LoadCB_id() -----------------------------------------------------------------> 第二个下拉款,根据第一个的选择,
显示下拉内容
{
string strCB_id = string.Format("select GoodsID from GoodsInfo where GoodsInfo.CompanyID=(select CompanyID from Company where CompanyName='{0}')", cb_Name.Text);
using (SqlConnection con =&nb