Results 1 to 4 of 4

Thread: User Control Problem

  1. #1

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    User Control Problem

    hi all,

    I am developing a server user control that has a DropDownList inside. I want my control to have a property that will expose the value of the DropDownList. Currently I am using the following to do so:
    VB Code:
    1. Public Property ControlValue() As Long
    2.         Get
    3.             Return ddList.SelectedItem.Value
    4.         End Get
    5.         Set(ByVal Value As Long)
    6.             ddList.SelectedIndex = Value
    7.         End Set
    8.     End Property
    where ddList is the DropDownList inside the User Control.
    Unfortunately the above code is not working, when I am trying to retrieve the ControlValue property I get the following error:
    System.NullReferenceException: Object reference not set to an instance of an object.

    In fact I also tried to use a reference to the ddlist but it still does not work, could anybody please help me on this...
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  2. #2

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378
    Is this a dormant forum or what????
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  3. #3
    Hyperactive Member
    Join Date
    Jan 2003
    Location
    Cape Cod, US
    Posts
    292
    This may not be one of the more happening groups but you do typically get good responses to valid questions (sometimes even in the *same* day)

    There's nothing wrong with your property definition AS LONG AS there is a selected item in the list. I just whipped up a test control that only contained a single drop down and pasted in your code. Had no problem with it as long as there is a selected item. When there is no selected item I get the same error message you mention.

    So you probably should program for that situation and return -1.

  4. #4

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Thumbs up

    Thanx, i'll try to have a look into that and give feedback if it works.
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width