|
protected void Page_Load (object sender, EventArgs e)
{
if (! Page.IsPostBack)
{
this.Bind ();
}
}
private void Bind ()
{
SqlConnection conn = DB.createcon ();
conn.Open ();
SqlCommand cmd = new SqlCommand ("select class, course from teaching plan, subject, teacher status table where teaching plan. Teacher = teacher status table. Teacher number and subject. ID = teaching plan. ID and teacher status table. Name = '" + Session ["TeacherName"]. ToString () + "'", conn);
SqlDataReader sda = cmd.ExecuteReader ();
// DataSet dss = new DataSet ();
//cmd.Fill(dss);
//this.DropDownList1.DataSource = dss;
//this.DropDownList1.DataBind ();
while (sda.Read ())
{
this.DropDownList1.DataSource = sda;
this.DropDownList1.DataTextField = "Class";
this.DropDownList1.DataValueField = "course";
this.DropDownList1.DataBind ();
}
sda.Close ();
SqlDataAdapter sdaa = new SqlDataAdapter ("select distinct name from basic information of student enrollment, teaching plan where basic information of student enrollment. Class = teaching plan. Class", conn);
DataSet ds = new DataSet ();
sdaa.Fill (ds);
this.DataGrid1.DataSource = ds;
this.DataGrid1.DataBind ();
conn.Close ();
}
protected void DropDownList1_SelectedIndexChanged (object sender, EventArgs e)
{
SqlConnection conn = DB.createcon ();
conn.Open ();
SqlDataAdapter sdaa = new SqlDataAdapter ("Select distinct name from basic information of student enrollment, teaching plan where basic information of student enrollment. Class = teaching plan. Class and basic information of student enrollment. Class = '" + DropDownList1.SelectedValue + "'," ;
DataSet ds = new DataSet ();
sdaa.Fill (ds);
this.DataGrid1.DataSource = ds;
this.DataGrid1.DataBind ();
conn.Close ();
}
protected void DataGrid1_PageIndexChanged1 (object source, DataGridPageChangedEventArgs e)
{
this.DataGrid1.SelectedIndex = e.NewPageIndex;
SqlConnection conn = DB.createcon ();
conn.Open ();
SqlDataAdapter sdaa = new SqlDataAdapter ("select distinct name from basic information of student enrollment, teaching plan where basic information of student enrollment. Class = teaching plan. Class", conn);
DataSet ds = new DataSet ();
sdaa.Fill (ds);
this.DataGrid1.DataSource = ds;
this.DataGrid1.DataBind ();
conn.Close ();
} |
|