|
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 班级,课程 from 授课方案,科目,教师情况表 where 授课方案.教师=教师情况表.教师编号 and 科目.ID=授课方案.ID and 教师情况表.姓名='" + 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 = "班级";
this.DropDownList1.DataValueField = "课程";
this.DropDownList1.DataBind();
}
sda.Close();
SqlDataAdapter sdaa = new SqlDataAdapter("select distinct 姓名 from 学生入学基本信息,授课方案 where 学生入学基本信息.班级=授课方案.班级", 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 姓名 from 学生入学基本信息,授课方案 where 学生入学基本信息.班级=授课方案.班级 and 学生入学基本信息.班级='"+DropDownList1.SelectedValue+"'", conn);
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 姓名 from 学生入学基本信息,授课方案 where 学生入学基本信息.班级=授课方案.班级", conn);
DataSet ds = new DataSet();
sdaa.Fill(ds);
this.DataGrid1.DataSource = ds;
this.DataGrid1.DataBind();
conn.Close();
} |
|