Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > How To Clone a DropDownList

Reply
Thread Tools

How To Clone a DropDownList

 
 
quiggle
Guest
Posts: n/a
 
      04-09-2004
I have a need to clone a dropDownList, passing all of the properties to the
new object, along with all of the originals eventHandlers.

I have been trying to use reflection to get all the properties, but continue
to get an error:
System.NullReferenceException: Object reference not set to an instance
of an object.

DropDownList clonedDropDown = new DropDownList();
System.Reflection.PropertyInfo[] properties = dd.GetType().GetProperties();
foreach(System.Reflection.PropertyInfo propInfo in properties )
{
object propValue = propInfo.GetValue(oldDropDown, null);
//(this is the line it complains about)
if ( propValue != null && propInfo.CanWrite)
propInfo.SetValue(clonedDropDown, propValue, null);
}

Also, I have no idea how to go about copying over the event handlers...Any
advice would be much appreciated!

Aimee


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
To clone or not to clone.. lordy Java 3 07-07-2006 04:30 PM
GridView: Filtr DropDownList from another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-23-2005 01:31 PM
databinding a Dropdownlist to another dropdownlist tshad ASP .Net 8 10-19-2005 10:00 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57