i want to have 2 listbox. the first listbox is for the Main category and the other one is for the sub category. and by using sql 2005 for the database. help me plz. . .
for example my main category for the 1st listbox is
and when i click one of the main categories it will
output the sub categories to the 2nd listbox.
To populate in listbox refer to the sample below:
lstboxName.DataSource = 'Here comes the datasource(dataset or any) you assign to the listbox.
lstboxName.DataValueField = "" 'Assign the column value that will be passed on selection.
lstboxName.DataTextField = "" 'Assign the column text that will be displayed in the listbox.
For fetching the selected items and passing to query refer to the sample below:
Dim selectedItem As String
If lstboxName.Items.Count > 0 Then
For i = 0 To lstboxName.Items.Count - 1
If lstboxName.Items(i).Selected Then
selectedItem = selectedItem + lstboxName.Items(i).Value.Trim() & ","
Dim selectedItemSplit As String() = selectedItem.ToString().Split(",")
Now pass the selectedItemSplit value either by as array or even you can pass with comma seperated as contained in selectedItem and pass to the select query and then populate it to the second listbox based on the selected value(s) in the first listbox.
Hope this helps!!!
Mark as "solved" if this helps to solve your requirement.
#define A 3// name a constant
long int booking_ID ; ...