Listboxes Contents Persist

Results 1 to 2 of 2

Thread: Listboxes Contents Persist

  1. #1
    Join Date
    Dec 1969

    Default Listboxes Contents Persist

    I have a two listboxes - start month and stop month. On the initial load, I populate start month with all the months of the year and select the month that is six months before today’s date. So for today, it would select May because May was 6 months ago. I populate stop month with all months starting from May to December and none before May.<BR><BR>I use the AutoPostBack property and SelectedIndexChanged event to try to repopulate the list boxes if the start month changes. So, if they change the start month from May to October, I want the stop month the repopulate itself with all months from October to December and none before October.<BR><BR>My problem is that it doesn’t appear to clear the listboxes after the SelectedIndexChanged event. My code to repopulate the control is actually appending to the previous contents. The control’s original contents persist after the event, which doesn’t make sense to me because it is firing the Page_Load event and the controls should clear themselves and start over.<BR><BR>So, how do I make the listboxes clear themselves so I can start over and repopulate them? Or, what is the right way to approach this design?<BR><BR>Thanks,<BR>clkou75

  2. #2

    Default RE: Listboxes Contents Persist

    The viewstate in maintaining the items you add, so when you add more, you will get more.<BR><BR>If you don&#039;t want it to keep them, you can set viewstate to false for the control

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts