|
-
Mar 5th, 2003, 04:06 AM
#1
Thread Starter
Hyperactive Member
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:
Public Property ControlValue() As Long
Get
Return ddList.SelectedItem.Value
End Get
Set(ByVal Value As Long)
ddList.SelectedIndex = Value
End Set
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...
-
Mar 5th, 2003, 07:58 AM
#2
Thread Starter
Hyperactive Member
Is this a dormant forum or what????
-
Mar 5th, 2003, 09:45 AM
#3
Hyperactive Member
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.
-
Mar 6th, 2003, 01:16 AM
#4
Thread Starter
Hyperactive Member
Thanx, i'll try to have a look into that and give feedback if it works.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|