I have 2 DropDownListboxes. both are based on a SQLDataSource control. When the value of one is changed, it acts as a filter on the other. The event fires fine, I change the filter on the SQLDataSource, but the list in the second DropDownList doesn't change.
I have been looking for an answer to this for hours and it's frustrating me greatly. It seems like it should be something simple like a requery command. The code in question is below.
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged If Me.DropDownList1.SelectedValue > 0 Then Me.SqlDataSource2.FilterExpression = "Arcft_Make_ID = " & Me.DropDownList1.SelectedValue Else Me.SqlDataSource2.FilterExpression = "" End If End Sub
End Ifline, adding
Me.DropDownList2.DataBind()Mike Guthrie 2012-04-04 01:00
If I'm not mistaken, you haven't really done anything by applying the FilterExpression. You still need to execute the query again. See the MSDN docs here. Relevant point at the top: "Gets or sets a filtering expression that is applied when the Select method is called.". So you need to call the Select method again.