This is a migrated thread and some comments may be shown as answers.

Dropdown being reset

1 Answer 41 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 19 Apr 2016, 12:55 PM
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;
}

1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 22 Apr 2016, 11:17 AM
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.
Tags
DropDownList
Asked by
Philip
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or