Hi..
I am using 2 Dropdowns in VB.net.In page loading i ll get the values from DB for the 1st dropdown for the second one i want to filter the values based on the first dropdown. can u tell me how to get the value for the second dropdown
Hi..
I am using 2 Dropdowns in VB.net.In page loading i ll get the values from DB for the 1st dropdown for the second one i want to filter the values based on the first dropdown. can u tell me how to get the value for the second dropdown
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mamta MPosted Mar 9, 2009, 4:12 AM
Hi,
Your question doesn't seem very clear. If you mean that, after a user selects a value in the first dropdown, you want the second dropdown to have filtered values based on that user selection, then that's quite easy and possible. All you need to do is get the selected element's index or value and construct a query (SELECT) statement with criteria based on the first dropdown selection to populate the second one.
For eg, for a listbox, you will use the SelectedItem property to retrieve the selected value.
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim selectedval = ListBox1.SelectedItem
. . .
End Sub
Hope that helps.
Regards,
Mamta