parent child dropdownlists acting oddly

C

Craig Buchanan

I've got two dropdownlists on my webusercontrol. Choosing an item from the
first DDL restricts the data displayed in the second DDL.

Unfortunately, in the SelectedIndexChanged event of the first DDL, the
SelectedIndex is -1. I'm not refreshing the contents of the first DDL on
the postback.

When I step thru the code, the Page_Load executes as expected, but I do get
an 'error' in the IDE when I step thru the code immediately after the this
event that reads: 'There is no source code for the current location'. I
don't know if this is affecting things or not. The SelectedIndexChange
event fires next, and indicates that SelectedIndex is -1.

Does anyone know what's happening? Code is below.

Thanks,

Craig Buchanan

<Code>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then BindData()
End Sub

Private Sub BindData()
BindDDL()
End Sub

Private Sub BindDDL()
With Me.DropDownList1
.DataSource = [stuff here]
.DataBind()
End With
End Sub

Private Sub BindLB(ByVal FolderId As Integer)
With ListBox1
.DataSource = [stuff here]
.DataBind()
End With
End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
If Me.ListBox1.SelectedIndex > -1 Then
Dim Value As Long = Me.ListBox1.SelectedItem.Value
Dim Text As String = Me.ListBox1.SelectedItem.Text
BindLB(Value)
End If
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListBox1.SelectedIndexChanged
If Me.ListBox1.SelectedIndex > -1 Then
Dim Value As Long = Me.ListBox1.SelectedItem.Value
Dim Text As String = Me.ListBox1.SelectedItem.Text
RaiseEvent ListClicked(Me, New ListControlEventArgs(Value, Text))
End If
End Sub

</Code>
 
C

Craig Buchanan

Looks like I'm testing for the listbox1 in the dropdownlist1's event.
Changed the test and everything worked!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top