1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Dynamically Generated Dropdown gets Cleared

Dynamically Generated Dropdown gets Cleared

3 posts, 0 answered
  1. Lonnie
    Lonnie avatar
    3 posts
    Registered:
    03 Oct 2011
    19 Oct 2011
    Link to this post
    I have a dynamicly generated dropdown list that keeps getting cleared when plugged into Sitefinity. I am using it inside a control. When I register the control outside of sitefinity it works fine but inside of sitefinity it gets reset before my submit button click event takes effect. 

    Dim year As Integer
                For year = System.DateTime.Now.Year To System.DateTime.Now.Year + 7
                    cboExpirationYear.Items.Add(year.ToString)
                Next

    Essentially it i were to select 2018 and click submit and have the click event display the year it displays 2011. 

    Any help would be appreciated. 

    Lonnie
  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    19 Oct 2011
    Link to this post
    Have you enabled viewstate on the page?  I think it's a checkbox on the page properties

    I BELIEVE by default viewstate is off (which is a good thing)
  3. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    21 Oct 2011
    Link to this post
    Hello Steve and Lonnie,

    Yes, view state is disabled by default so you should enable it for this page. Otherwise data in such drop downs will be lost between page postbacks.

    Regards,
    Lubomir Velkov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
3 posts, 0 answered