protected void Page_Load(object sender, EventArgs e) { Meta.NodeCode = "104004"; sx = Request.QueryString["sx"]; DateTime tnow = DateTime.Now;//现在时间 Response.Write(tnow); ArrayList AlYear = new ArrayList(); AlYear.Add("Year"); int i; for (i = 2015; i <= int.Parse(tnow.Date.Year.ToString()); i++) { AlYear.Add(i); } ArrayList AlMonth = new ArrayList(); AlMonth.Add("Month"); for (i = 1; i <= 12; i++) { AlMonth.Add(i); } if (!this.IsPostBack) { DDlYear.DataSource = AlYear; DDlYear.DataBind();//绑定年 //选择当前年 // DDlYear.SelectedValue = tnow.Year.ToString(); DDlYear.SelectedValue = "Year"; DDLMonth.DataSource = AlMonth; DDLMonth.DataBind();//绑定月 //选择当前月 // DDLMonth.SelectedValue = tnow.Month.ToString(); DDLMonth.SelectedValue = "Month"; BindData(); BindActivityTop(); BindActivity(); } }
/// <summary> /// Initialize the drop down controls. /// </summary> public void Initialize() { DBAccess MonthYear = new DBAccess(); MonthYear.CommandText = "dbo.MonthYear"; DataSet DDLData = MonthYear.ExecuteDataSet(); //Bind DDLMonth DDLMonth.DataSource = DDLData; DDLMonth.DataMember = DDLData.Tables[0].TableName; DDLMonth.DataValueField = "ID"; DDLMonth.DataTextField = "Month"; DDLMonth.DataBind(); //Bind DDLYear DDLYear.DataSource = DDLData; DDLYear.DataMember = DDLData.Tables[1].TableName; DDLYear.DataValueField = "Year"; DDLYear.DataTextField = "Year"; DDLYear.DataBind(); PlaceHolder1.Controls.Clear(); Panel1.Visible = true; Panel2.Visible = false; }