public void GridViewBind()
    {
        Apartment apartment = new Apartment();
        DataSet   ds        = apartment.GetAllApartment();

        this.GridView1.DataSource = ds;
        this.GridView1.DataBind();
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if ((Session["adminUserName"] == null) && (Session["adminUserRole"] == null))
     {
         Response.Redirect("../error.aspx");
     }
     if (!IsPostBack)
     {
         //初始化公寓编号下拉框的内容
         ListItem li = new ListItem("请选择", "");
         this.apartmentNo.Items.Add(li);
         Apartment apartment = new Apartment();
         DataSet   ds        = apartment.GetAllApartment();
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             DataRow dr = ds.Tables[0].Rows[i];
             li = new ListItem(dr["apartmentNo"].ToString(), dr["apartmentNo"].ToString());
             this.apartmentNo.Items.Add(li);
         }
         //然后初始化学年下拉框的内容
         ListItem li2 = new ListItem("请选择", "");
         this.appraisalYear.Items.Add(li2);
         Appraisal appraisal = new Appraisal();
         DataSet   ds2       = appraisal.GetAppraisalYear();
         for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
         {
             DataRow dr = ds2.Tables[0].Rows[i];
             li2 = new ListItem(dr["appraisalYear"].ToString(), dr["appraisalYear"].ToString());
             this.appraisalYear.Items.Add(li2);
         }
         //再初始化学期下拉框的内容
         ListItem li3 = new ListItem("请选择", "");
         this.appraisalTerm.Items.Add(li3);
         DataSet ds3 = appraisal.GetAppraisalTerm();
         for (int i = 0; i < ds3.Tables[0].Rows.Count; i++)
         {
             DataRow dr = ds3.Tables[0].Rows[i];
             li3 = new ListItem(dr["appraisalTerm"].ToString(), dr["appraisalTerm"].ToString());
             this.appraisalTerm.Items.Add(li3);
         }
         //最后绑定GridView控件中的数据
         GridViewBind();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if ((Session["adminUserName"] == null) && (Session["adminUserRole"] == null))
     {
         Response.Redirect("../error.aspx");
     }
     if (!IsPostBack)
     {
         ListItem li = new ListItem("请选择", "");
         this.apartmentNo.Items.Add(li);
         Apartment apartment = new Apartment();
         DataSet   ds        = apartment.GetAllApartment();
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             DataRow dr = ds.Tables[0].Rows[i];
             li = new ListItem(dr["apartmentNo"].ToString(), dr["apartmentNo"].ToString());
             this.apartmentNo.Items.Add(li);
         }
     }
 }