Results 1 to 2 of 2

Thread: populating lbo from dropdownlist

  1. #1

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    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:
    1. Private Sub refresh_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles refresh.Click
    2.         'Get staffnames by region
    3.         Dim str_Region As String = staffRegion.SelectedItem.Text 'ddlist
    4.  
    5.        
    6.         Dim Source As New DataTable
    7.         Source = CType(Application("Staff"), DataTable)
    8.  
    9.         For Each row As DataRow In Source.Rows
    10.             If row("RegionName") = str_Region Then
    11.                 Me.StaffList.Items.Add(New ListItem(row("FullName"), row("id")))
    12.             End If
    13.         Next
    14.  
    15.     End Sub

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    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"])

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width