示例#1
0
 protected void LoadForMonth()
 {
     try
     {
         DdlMonth.Items.Clear();
         DdlMonthDet.Items.Clear();
         DateTime now = new DateTime();
         now = DateTime.Today;
         for (int i = -11; i < 2; i++)
         {
             DateTime date = now.AddMonths(i);
             DdlMonth.Items.Add(
                 new ListItem(date.ToString("MMM yyyy"), date.ToString("MMM yyyy")));
             DdlMonthDet.Items.Add(
                 new ListItem(date.ToString("MMM yyyy"), date.ToString("MMM yyyy")));
         }
         DdlMonth.DataBind();
         DdlMonthDet.DataBind();
         DdlMonth.Items.Insert(0, "Please Select");
         DdlMonthDet.Items.Insert(0, "Please Select");
         DdlMonth.SelectedValue    = now.ToString("MMM yyyy");
         DdlMonthDet.SelectedValue = now.ToString("MMM yyyy");
     }
     catch (Exception ex)
     {
     }
 }