-2

I have a dropdown list with 4 values. I'm trying to add an If statement in the event that a value is selected from the dropdown list. Each value in the dropdown list enables another dropdown list later on in the form. I have no syntax errors when I run the code, but it still doesn't work. No mater what value I select the rest of the form stays disabled.

Code below:

    Protected Sub FunctionPerformedDD_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles FunctionPerformedDD.SelectedIndexChanged

    If (FunctionPerformedDD.SelectedIndex.Equals(0)) Then

    ElseIf (FunctionPerformedDD.SelectedIndex.Equals(1)) Then

        ReportDD.Enabled = True

    ElseIf (FunctionPerformedDD.SelectedIndex.Equals(2)) Then

        FormDD.Enabled = True

    Else
        FormDD.Enabled = True

    End If

End Sub
Hasib Ibradzic
  • 29
  • 1
  • 12
  • 1
    Your code says, select the first item, do nothing, select the second item, enable the ReportDD, select the third or fourth item, enable the FormDD. Use the debugger. Watch what happens when you select an item from the list. – LarsTech Feb 25 '15 at 18:21
  • When I used the debugger my program would never break into the code, so that's how I found out that the problem wasn't with the code. The problem was with the DropDownList properties. Once I changed the AutoPostBack property then the code worked correctly. – Hasib Ibradzic Feb 26 '15 at 18:54
  • 1
    Right, but there was nothing in your question that would have told us that. You didn't tag your question with ASP.Net, etc. This *looked like* a winforms question to me. – LarsTech Feb 26 '15 at 18:59
  • Yeah I'm new at this, so I didn't even know I was coding in ASP.net. I thought everything in Visual Studios was VB.net – Hasib Ibradzic Feb 27 '15 at 21:53

1 Answers1

0

The problem was that I needed to set the AutoPostBack property for the dropdown list to True.

Hasib Ibradzic
  • 29
  • 1
  • 12