Dynamic dropdows appending not replacing second dropdown items

  • Thread starter Thread starter seanmayhew
  • Start date Start date
S

seanmayhew

Im attempting to get the vaules for the second drop down on index
changed of the first. This works fine. However rather than just
replacing the values of the second drop down with the new values its
just appending them. On each post back.

ie
myddlOne.item = fruit;
myddlOne.item = vegetable;

select fruit returns
myddlTwo.item = orange;
myddlTwo.item = apple;

select vegetable after selecting fruit returns
myddlTwo.item = orange;
myddlTwo.item = apple;
myddlTwo.item = green bean;
myddlTwo.item = broccoli;

I know this is posted somewhere I searched for an hour and could not
find it... any help greatly appreciated.
 
You're probably populating the second ddl in the page_load event, when you
are changing the value in the first dropdown it is performing a postback and
running through page_load again, wrap your code that populates the second
ddl in a check for page.ispostback,

If (page.ispostback = false) Then 'Is only false on first entry...
'ddl population here
End If

regards,
J.
 
Back
Top