Example #1
0
 public static void LoadSubYear(ref DropDownList cmbSubYear, int yearId
                                , bool emptySelection   = false
                                , bool topAsInitial     = false
                                , bool onlyTopLevelLoad = false
                                , bool allField         = false)
 {
     cmbSubYear.DataTextField  = "Name";
     cmbSubYear.DataValueField = "Id";
     //int proId = Convert.ToInt32((
     //    cmbProgram.SelectedValue.ToString() == "") ? "0" : cmbProgram.SelectedValue.ToString());
     using (var helper = new DbHelper.Structure())
     {
         var yea = helper.GetSubYears(yearId, onlyTopLevelLoad);
         if (allField)
         {
             if (yea.Count < 0)
             {
                 yea.Insert(0, new SubYear()
                 {
                     Id = 0, Name = "None"
                 });
             }
             else
             {
                 yea.Insert(0, new SubYear()
                 {
                     Id = 0, Name = "All"
                 });
             }
         }
         else if (topAsInitial)
         {
             yea.Insert(0, new SubYear()
             {
                 Id = 0, Name = "Top"
             });
         }
         else if (emptySelection)
         {
             yea.Insert(0, new SubYear()
             {
                 Id = 0, Name = ""
             });
         }
         else if (yea.Count > 0)
         {
             yea.Insert(0, new SubYear()
             {
                 Id = 0, Name = "---Select One---"
             });
         }
         cmbSubYear.DataSource = yea;
         cmbSubYear.DataBind();
     }
 }