protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CourseTableBLL ctBLL = new CourseTableBLL(); ClassBLL classBLL = new ClassBLL(); CourseBLL courBLL = new CourseBLL(); TeacherBLL teachBLL = new TeacherBLL(); DropDownList_class.DataSource = classBLL.getAll(); DropDownList_class.DataTextField = "name"; DropDownList_class.DataValueField = "ID"; DropDownList_class.DataBind(); DropDownList_course.DataSource = courBLL.getByClassId(DropDownList_class.SelectedValue); DropDownList_course.DataTextField = "name"; DropDownList_course.DataValueField = "ID"; DropDownList_course.DataBind(); string filterTeacher = "classID='" + DropDownList_class.SelectedValue + "' and courId='" + DropDownList_course.SelectedValue + "'"; DataTable tempDt = PageUtil.getProcessedDataTable(ctBLL.getAll().Tables[0], filterTeacher, null, false); DataView dv = tempDt.DefaultView; tempDt = dv.ToTable(true, "teachID"); foreach (DataRow dr in tempDt.Rows) { Teacher teacher = teachBLL.get(dr["teachID"].ToString()); DropDownList_teacher.Items.Add(new ListItem(teacher.Name, teacher.Id)); } bind(); } }