locked
Using results of autocomplete function on textchange to trigger other queries RRS feed

  • Question

  • User-365171684 posted

    Hello,

    I have an autocomplete webservice returning "Lastname, Firstname" from a tableadapter. I want to pass that string to another tableadapter and then the result of that to yet another.

    My table adapters all work fine if I hardcode values into them ....but im not sure of a few things.

    1- Is this the most effiecient way to retrive these values...Im sure I will need more data as i build this, do I just keep adding tableadapters? Im thinking not..

    2- How do I pass the results from one function to the next.

     

     <System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()>
        Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer, ByVal contextKey As String) As String()
    
            Dim strResults(1) As String
    
            Dim ACref As New ACWebService
            strResults = ACref.GetAutoCompletes(prefixText)
    
            Return strResults
    
        End Function
    
     Protected Sub txtAutoComplete_TextChanged(sender As Object, e As EventArgs) Handles txtAutoComplete.TextChanged
            Dim ACTA As New AutoCompleteTableAdapters.bbs_Employees1TableAdapter
            Dim ACDA As New AutoComplete.bbs_Employees1DataTable
            ACTA.Fill(ACDA, "Smith", "John")
    
            TxtEmpID.Text = ACDA(0).Item("Emp_ID").ToString
    
            ACDA.Clear()
            ACTA.Dispose()
        End Sub
    
        Protected Sub txtAutoComplete_TextChanged2(sender As Object, e As EventArgs) Handles txtAutoComplete.TextChanged
            Dim ACTA As New AutoCompleteTableAdapters.bbs_Employees2TableAdapter
            Dim ACDA As New AutoComplete.bbs_Employees2DataTable
            ACTA.Fill(ACDA, "339")
    
            TxtEmpShift.Text = ACDA(0).Item("Emp_CurrentShift").ToString
    
            ACDA.Clear()
            ACTA.Dispose()
        End Sub
    
    
        Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    
        End Sub
    End Class
    


     

    Tuesday, August 27, 2013 2:57 PM

Answers

  • User-365171684 posted

    Here's how I ended up doing it...

     

     Protected Sub TextBox17_TextChanged(sender As Object, e As EventArgs) Handles TextBox17.TextChanged
            Dim ACTA As New DataSetTableAdapters.GetDataTableAdapter
            Dim ACDA As New DataSet.GetDataDataTable
            Dim Fullname() As String = Split(TextBox17.Text, ",", -1, CompareMethod.Text)
            ACTA.Fill(ACDA, Trim(Fullname(0)), Trim(Fullname(1)))
            TextBox18.Text = ACDA(0).Item("Emp_ID").ToString
            Dim ShiftList As String = ACDA(0).Item("Emp_CurrentShift").ToString
            Dim DeptList As String = ACDA(0).Item("Department").ToString
            TextBox20.Text = Date.Today.ToShortDateString
    
            ACDA.Clear()
            ACTA.Dispose()
    
            Dim DPTA As New DataSetTableAdapters.AreasTableAdapter
            Dim DPDA As New DataSet.AreasDataTable
            DPTA.Fill(DPDA)
            For D = 0 To DPDA.Rows.Count - 1
                DropDownList9.Items.Add(DPDA(D).Item("Department"))
            Next
            DropDownList9.SelectedValue = DeptList
    
            Dim SHTA As New DataSetTableAdapters.ShiftTableAdapter
            Dim SHDA As New DataSet.ShiftDataTable
            SHTA.Fill(SHDA)
            For D = 0 To SHDA.Rows.Count - 1
                DropDownList10.Items.Add(SHDA(D).Item("Emp_CurrentShift"))
            Next
            DropDownList10.SelectedValue = ShiftList
    
    
        End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 18, 2013 5:26 PM

All replies

  • User-1360095595 posted

    Can you explain why you're doing all this jumping around? Why can't this be done with one query?

    Tuesday, August 27, 2013 3:45 PM
  • User-365171684 posted

    Im not very experienced but thats what I was thinking to myself as well.

    The first query is an autocomplete for the name. Once I get that and the text changes, my thought was to take that result and feed it to the next query for a textbox to display the EmpID and then feed that to another to get the EmpShift in another textbox. What your saying, I think, is make the 2nd query get everything once I have the name?

    Tuesday, August 27, 2013 4:39 PM
  • User-1360095595 posted

    Indeed I think two queries should do it. The first for the autocomplete and another for the other two textboxes together. Of course, assuming your database/schema will allow for that.

    Tuesday, August 27, 2013 5:18 PM
  • User-365171684 posted

    Here's how I ended up doing it...

     

     Protected Sub TextBox17_TextChanged(sender As Object, e As EventArgs) Handles TextBox17.TextChanged
            Dim ACTA As New DataSetTableAdapters.GetDataTableAdapter
            Dim ACDA As New DataSet.GetDataDataTable
            Dim Fullname() As String = Split(TextBox17.Text, ",", -1, CompareMethod.Text)
            ACTA.Fill(ACDA, Trim(Fullname(0)), Trim(Fullname(1)))
            TextBox18.Text = ACDA(0).Item("Emp_ID").ToString
            Dim ShiftList As String = ACDA(0).Item("Emp_CurrentShift").ToString
            Dim DeptList As String = ACDA(0).Item("Department").ToString
            TextBox20.Text = Date.Today.ToShortDateString
    
            ACDA.Clear()
            ACTA.Dispose()
    
            Dim DPTA As New DataSetTableAdapters.AreasTableAdapter
            Dim DPDA As New DataSet.AreasDataTable
            DPTA.Fill(DPDA)
            For D = 0 To DPDA.Rows.Count - 1
                DropDownList9.Items.Add(DPDA(D).Item("Department"))
            Next
            DropDownList9.SelectedValue = DeptList
    
            Dim SHTA As New DataSetTableAdapters.ShiftTableAdapter
            Dim SHDA As New DataSet.ShiftDataTable
            SHTA.Fill(SHDA)
            For D = 0 To SHDA.Rows.Count - 1
                DropDownList10.Items.Add(SHDA(D).Item("Emp_CurrentShift"))
            Next
            DropDownList10.SelectedValue = ShiftList
    
    
        End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 18, 2013 5:26 PM