At the moment of selecting a data in the first DropDownList1
, in the second DropDownList2
, it will filter with an query of SQL and the new data will be placed in its list.
At the moment I only have this method:
public void dropdowns() {
SqlConnection cn = new SqlConnection("CadenaDeConexion");
SqlCommand cmd = new SqlCommand("select CustomerNumber FROM tbl_Customer where CustomerSitie='"+DropDownList1.Text +"'", cn);
cn.Open();
SqlDataReader leer = cmd.ExecuteReader();
if (leer.Read() == true)
{
DropDownList2.Text = leer["CustomerNumber"].ToString();
}
cn.Close();
}
But do not fucniona with TextChanged
, only with button:
protected void DropDownList2_TextChanged(object sender, EventArgs e)
{
dropdowns();
}
protected void Button2_Click(object sender, EventArgs e)
{
dropdowns();
}