populating lbo from dropdownlist
Guys,
I have a dropdown list and a listbox on a user control. The ddlist is populated with UK regions. When the selecteditem is changed, I want to populate the listbox with staff in that region. I have a button (refresh) on screen that should take the selecteditem.text and return matching staff into the lbo.
Why doesn't this work ? Everytime I refresh it is returning staff, but just those that match the first item in the list.
Thanks
Bob
VB Code:
Private Sub refresh_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles refresh.Click
'Get staffnames by region
Dim str_Region As String = staffRegion.SelectedItem.Text 'ddlist
Dim Source As New DataTable
Source = CType(Application("Staff"), DataTable)
For Each row As DataRow In Source.Rows
If row("RegionName") = str_Region Then
Me.StaffList.Items.Add(New ListItem(row("FullName"), row("id")))
End If
Next
End Sub
Re: populating lbo from dropdownlist
You'll find that, in your page initialisation (Form_Load probably), you're re-loading the data contents. You can fix this by wrapping a postback check around the population, or by getting the values from the posted form name/value collection (e.g. Request.Form["ddllist"])