How To Clone a DropDownList

Discussion in 'ASP .Net Building Controls' started by quiggle, Apr 9, 2004.

  1. quiggle

    quiggle Guest

    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
     
    quiggle, Apr 9, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mdb
    Replies:
    1
    Views:
    770
  2. Konrad Eisele

    Arm clone version 0_8

    Konrad Eisele, Apr 7, 2004, in forum: VHDL
    Replies:
    0
    Views:
    688
    Konrad Eisele
    Apr 7, 2004
  3. Kohn J. Wrahn
    Replies:
    0
    Views:
    2,895
    Kohn J. Wrahn
    May 25, 2005
  4. Felix

    clone a datagrid

    Felix, Dec 4, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,894
    Felix
    Dec 4, 2003
  5. lordy

    To clone or not to clone..

    lordy, Jul 7, 2006, in forum: Java
    Replies:
    3
    Views:
    731
    lordy
    Jul 7, 2006
Loading...

Share This Page