2

Using a SQL datasource to filter the options in drop down list from an onclick link button

Ultimately I have a drop down list that show all individuals. I'm wanting the user to be able to click a link button(A-Z) so the options in the drop down list only hold the names that fall into the link button's category. SP is already written just unsure of how exactly to tie the link button and drop down list with out writing code per link button. I'm wanting to use a data view for this. So on my aspx page I have the datasource set up and pointing to the drop down list but not sure on how to code it..

1
  • if this is web, you could use Jquery UI Autocomplete? Commented Nov 8, 2013 at 15:24

1 Answer 1

1

Lets say that you have a datatable with columns ID and NAME.
Then in its link button you can use :

    Private Sub FilterNames(ByVal letter As String)
    Dim items = (From p In dt
            Select New With {.Name = p.Field(Of String)("NAME"),
                             .ID = p.Field(Of Integer)("ID")}).ToList()

    Dim filtered = items.Where(Function(x) x.Name.ToUpper.StartsWith(letter)).ToList()

    ComboBox1.DataSource = filtered
    ComboBox1.DisplayMember = "NAME"
    ComboBox1.ValueMember = "ID"
End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

Nianios I thought this would work but it doesn't quite fit into what I'm wanting to do. Hope the edit makes it easier to understand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.