How to copy items from one DropDownList control to another DropDownList control.

The following code shows how to copy items from one DropDownList control to another DropDownList control.


foreach (ListItem item in drop1.Items)
{
drop2.Items.Add(item);
}


Where drop1 is the id of first DropDownList and drop2 is the id of second DropDownList control.


Comments

Author: Kapil Dhawan17 Jun 2008 Member Level: Gold   Points : 2

Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side

I hope this code wil help lots of guys

Regards,
Kapil



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: