Dropdown being reset

2 posts, 0 answers
  1. Philip
    Philip avatar
    69 posts
    Member since:
    Mar 2016

    Posted 19 Apr Link to this post

    For some reason my drop down is getting reset on my page load i popuplate the dropdown by trapping the post back.
    protected void Page_Load(object sender, EventArgs e)
           {
               tblApertureNetShiftPattern _shifts = new tblApertureNetShiftPattern();
               string timeCode = "";
     
               string id = Request.QueryString["id"];
     
               Guid _guid = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id);
     
               _shifts = _dal.GetShiftPatternById(_guid);
     
               if (Request.Browser.Browser == "Firefox")
                   Form.Attributes.Add("autocomplete", "off");
     
     
               if (!IsPostBack)
               {
                   var dlManagersSource = _dal.GetManagers();
                   rdManagers.DataSource = dlManagersSource;
                   rdManagers.DataValueField = "LookupValue";
                   rdManagers.DataTextField = "LookupDescription";
                   rdManagers.DataBind();
     
                   // Then add your first item
                   var ddlDaysOfWeek = _dal.GetDaysOfWeek().OrderBy(o => o.Order);
                   rdDayOfWeek.DataSource = ddlDaysOfWeek;
                   rdDayOfWeek.DataValueField = "LookupValue";
                   rdDayOfWeek.DataTextField = "LookupDescription";
                   rdDayOfWeek.DataBind();
     
                   var ddlShiftPatterns = _dal.GetShiftPatternTypes();
                   rdAppointmentType.DataSource = ddlShiftPatterns;
                   rdAppointmentType.DataValueField = "LookupValue";
                   rdAppointmentType.DataTextField = "LookupDescription";
                   rdAppointmentType.DataBind();
               }
     
               txtDescription.Text = _shifts.Description;
                   rdStartShift.SelectedDate = _shifts.startdate;
                   rdShiftEnd.SelectedDate = _shifts.endDate;
                   rdDayOfWeek.SelectedValue = _shifts.dayOfWeek.ToString();
                   rdAppointmentType.SelectedValue = _shifts.appointmentType.ToString();
                   rdManagers.SelectedValue = _shifts.manager_Id.ToString();
              
               
           }

     

    /// <summary>
    /// Gets the days of week.
    /// </summary>
    /// <returns></returns>
    public List<StandardLookup> GetDaysOfWeek()
    {
        List<StandardLookup> lookups = new List<StandardLookup>();
     
        try
        {
            var q = from lookup in apertureNetEntities.tblApertureNetLookUps.Where(a => a.lookup_type == Constants.daysOfWeek).OrderByDescending(o => o.colOrder)
                    orderby lookup.lookup_description
                    select new
                    {
                        LookLookupValue = lookup.lookup_Code,
                        LookupDescription = lookup.lookup_description.Trim(),
                        Order = lookup.colOrder
                    };
     
            if (q != null)
            {
                Array.ForEach(q.ToArray(), l =>
                {
                    lookups.Add(new StandardLookup(l.LookLookupValue, l.LookupDescription, l.Order));
                });
            }
        }
        catch (Exception ex)
     
        {
            string inner = string.Empty;
            if (ex.InnerException != null)
            {
                inner = ex.InnerException.ToString();
            }
            logger.Error("Error in GetDaysOfWeek function aperturenetdal " + ex.ToString() + " " + inner);
            return null;
        }
     
        return lookups;
    }

  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 22 Apr Link to this post

    Hello Phillip,

    As stated in the other forum thread that you have submitted - I am afraid that the provided information is not sufficient, in order to determine the reason for the reset data of the DropDownList. I am afraid that the Data Source, the exact implementation of the control and other references to methods are missing.

    This is why, I would suggest you to submit a support ticket, along with a runnable sample attached, where the problem resides.

    Regards,
    Nencho
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top