shahab
Junior Contributor
Code:
void DDL1Binder()
{
string strCon = ConfigurationSettings.AppSettings["ConnStr"];
SqlConnection wg = new SqlConnection(strCon);
SqlDataAdapter dtAdap1 = new
SqlDataAdapter("select major from tblQCategory ",wg);
dtAdap1.Fill(ds1, "tblQCategory");
DropDownList1.DataSource = ds1.Tables["tblQCategory"].DefaultView;
DropDownList1.DataBind();
}
//--------------------------------------------------------------------------
void DDL2Binder()
{
string strCon = ConfigurationSettings.AppSettings["ConnStr"];
SqlConnection wg = new SqlConnection(strCon);
SqlDataAdapter dtAdap2 = new
SqlDataAdapter("select lesson from tblQCategory "
//+" WHERE major = '" + DropDownList1.SelectedItem.Text.ToString() +"'",wg);
//+" WHERE major = '" + DropDownList1.DataTextField.ToString()+"'",wg); False
//+" WHERE major = '" + DropDownList1.SelectedItem.Text.Trim() +"'",wg); False
//+" WHERE major = N'ادبیات'",wg); True
dtAdap2.Fill(ds2, "tblQCategory");
DropDownList2.DataSource = ds2.Tables["tblQCategory"].DefaultView;
DropDownList2.DataBind();
}
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
//DDL2Binder();
}
+" WHERE major = '" + DropDownList1.SelectedItem.Text.ToString() +"'",wg);