protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { String selectQuery = "Select id, name from Semesters where course_id='" + RadioButtonList1.SelectedItem.Value + "'"; SqlCommand cmd = new SqlCommand(selectQuery); cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); DDLSemester.DataSource = cmd.ExecuteReader(); DDLSemester.DataTextField = "name"; DDLSemester.DataValueField = "id"; DDLSemester.DataBind(); con.Close(); selectQuery = "Select id, name from Faculties where course_id='" + RadioButtonList1.SelectedItem.Value + "'"; cmd = new SqlCommand(selectQuery); cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); DDLFName.DataSource = cmd.ExecuteReader(); DDLFName.DataTextField = "name"; DDLFName.DataValueField = "id"; DDLFName.DataBind(); con.Close(); }
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { String selectQuery = "Select DISTINCT Semesters.name, Semesters.id from Semesters,subject_faculty,Subjects,Faculties where subject_faculty.faculty_id=Faculties.id AND subject_faculty.sub_id=Subjects.id AND Semesters.id=Subjects.semester_id AND Faculties.email='" + Session["CurrentUser"] + "'"; //String selectQuery = "Select id, name from Semesters where course_id='" + RadioButtonList1 .SelectedItem.Value + "'"; SqlCommand cmd = new SqlCommand(selectQuery); cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); DDLSemester.DataSource = cmd.ExecuteReader(); DDLSemester.DataTextField = "name"; DDLSemester.DataValueField = "id"; DDLSemester.DataBind(); con.Close(); selectQuery = "Select id, name from Students where course_id='" + RadioButtonList1.SelectedItem.Value + "'"; cmd = new SqlCommand(selectQuery); cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); DDLFName.DataSource = cmd.ExecuteReader(); DDLFName.DataTextField = "name"; DDLFName.DataValueField = "id"; DDLFName.DataBind(); con.Close(); //selectQuery = "Select id, name from Subjects where course_id='" + RadioButtonList1.SelectedItem.Value + "' AND semester_id='"+DDLSemester.Items[0].Value+"'"; selectQuery = "Select DISTINCT Subjects.name, Subjects.id from Courses,subject_faculty,Subjects,Faculties,Semesters" + " where subject_faculty.faculty_id=Faculties.id AND subject_faculty.sub_id=Subjects.id AND Courses.id=Subjects.course_id AND Subjects.semester_id=Semesters.id" + " AND Faculties.email='" + Session["CurrentUser"] + "' AND Courses.id=" + RadioButtonList1.SelectedItem.Value + " And Semesters.id=" + DDLSemester.SelectedItem.Value; cmd = new SqlCommand(selectQuery); cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); DDLSubject.DataSource = cmd.ExecuteReader(); DDLSubject.DataTextField = "name"; DDLSubject.DataValueField = "id"; DDLSubject.DataBind(); con.Close(); }