Q
quiggle
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
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