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:
(RouteSettings is the ID of the panel).
I then try either of these arguments, that returns the following errors:
returns the error
returns the error
What am I doing wrong?
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:
Dim ddl As DropDownList = DirectCast(RouteSettings.FindControl("NumberOfPlanesList"), DropDownList)
I then try either of these arguments, that returns the following errors:
VB.NET:
Dim selectedValue As Integer = CInt(ddl.SelectedItem.Value)
.System.NullReferenceException: Object reference not set to an instance of an object.
VB.NET:
Dim selectedValue As Integer = CInt(ddl.SelectedValue)
.System.FormatException: Input string was not in a correct format.
What am I doing wrong?