Dynamic dropdows appending not replacing second dropdown items

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.
 
J

J

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top