private void BindDDL() {
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; string
SqlStr
=
"SELECT
distinct
cource.courceID,cource.courceName
from
Elect,Cource
where
Elect.courceID=Cource.courceID and Elect.teaID='"+Session["userName"].ToString() +"'"; DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(connStr); if (conn.State.ToString() == "Closed") conn.Open();
SqlDataAdapter da = new SqlDataAdapter(SqlStr, conn); da.Fill(ds); if (conn.State.ToString() == "Open") conn.Close();
ddlCource.DataSource = ds.Tables[0].DefaultView; ddlCource.DataTextField = "courceName"; ddlCource.DataValueField = "courceID"; ddlCource.DataBind(); }
}
3、教师界面的设计
教师界面的设计相对要简单一些,只有一个gridview的创建。创建完成后的界面如下:
添加后台代码(在设计里面的空白处双击或者在职员管理器中的Login.aspx.cs中添加)如下: