Question Dropdownlist problem

Coffer

Member
Joined
Jun 26, 2009
Messages
7
Programming Experience
5-10
Hello!
I have a panel that is viewable if certain conditions are met. Inside this panel I have a dropdownlist that is dynamically populated with information and a submit-button. When I hit the submit, it's supposed to - among other things - grab a selected value from the dropdownlist and insert it into a database. Unfortunately it seems as if the selection is empty all the time.

I try to catch the selected value this way:
VB.NET:
Expand Collapse Copy
Dim ddl As DropDownList = DirectCast(RouteSettings.FindControl("NumberOfPlanesList"), DropDownList)
(RouteSettings is the ID of the panel).

I then try either of these arguments, that returns the following errors:
VB.NET:
Expand Collapse Copy
Dim selectedValue As Integer = CInt(ddl.SelectedItem.Value)
returns the error
System.NullReferenceException: Object reference not set to an instance of an object.
.
VB.NET:
Expand Collapse Copy
Dim selectedValue As Integer = CInt(ddl.SelectedValue)
returns the error
System.FormatException: Input string was not in a correct format.
.

What am I doing wrong?
 
Back
Top