Use autocomplete textbox to refill gridview

WOndering if its possible to use a atuocomplete extender textbox outside of a datagriid to refresh data in grid as you type a name.  So I load the grid initially with information and then as I type in my textbox I want information in grid to fall away till i get to the person I want.  Is this possible??? and where do i start.

If its possible I will add full amount of points.
kdeutschAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TomasPCommented:
I would start by capturing each character entered in the text box and then scan the grid for entries that match my character and remove the rest. Keep in mind you should copy the data out of the grid first so if the user backspaces you can restore information to the grid as appropriate
Also, the logic depends if you are just trimming data already in the grid or forcing a new population of data in the grid from the store based on what the user enters. If you populate the grid with the first records and the user's first letter requires records not yet read in, they you need to build a query according and pull the data from the store according per the new query.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Avinash DesaiSr Software EngineerCommented:
Hi

Get the data to the DataTable and assign the DataTable to the Binding source and bind the same to  Gridview using its DefaultView Property of Datatable you can filter the data .

Please refer the sample code below.

Dim DT as new Datatable
Dim Bs As new BindingSource


'Get the data to the Table
'Now assuming Data is in DT Datatable

'Bind the Same to the BindingSource
BS.DataSource = DT.DefaultView
DataGridView.DataSource = BS



'On TEXT BOX TEXT CHANGE EVENT WRITE THIS CODE TO FILTER THE DATA IN THE GRIDVIEW
DT.DefaultView.RowFilter = "ColoumnName Like '%" & Textbox1.Text & "%'"



This works fine. please let me know if any errors


0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

kdeutschAuthor Commented:
Hi,

Ok here is my code, what I do is fill the Gridview on a dropdown list event, then fill the gridview.
  Protected Sub ddlTasks_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlTasks.SelectedIndexChanged
        pnlGrid.Visible = True
        FillGrid()
    End Sub

    Protected Sub txtFindSoldier_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFindSoldier.TextChanged
        FillGrid()
    End Sub

    Private Sub FillGrid()
        Dim srp As Integer = ddlSrpEvent.SelectedValue
        Dim cat As Integer = ddlTasks.SelectedValue
        Dim theCounter As Integer
        Dim SqlWhere As String

        If HFID.Value = "" Then
            SqlWhere = ""
        Else
            SqlWhere = "AND ed.intPersonnelID = '" & HFID.Value & "'"
        End If

        sql = "Select ed.intDataId, q.strTask, ed.intAnswer as Answer, ed.strData, ed.strRemarks, strDocDate, w.strFullName From tblSRPEventData as ed INNER JOIN tblSRPQuestion as q on " _
            & "q.intQuestionId = ed.intQuestionId INNER JOIN " _
            & "tblQuestionCategory as qc on qc.intCategoryId = q.intCategoryID INNER JOIN WORSDotNet.dbo.tblUser as w on w.strSSN = cast(ed.intPersonnelID as varchar) Where q.intcategoryId = " & cat & " and " _
            & "intEventId = " & srp & " and intAnswer = 1 " & SqlWhere & " Order by w.strFullname"

        myGridview.DataSource = getData(sql)
        myGridview.DataBind()

        For theCounter = 0 To myGridview.Rows.Count - 1

        Next

        lblCount.Text = theCounter & " Records"

        'Wipe the HFID for onload events
        HFID.Value = Nothing
        txtFindSoldier.Text = String.Empty
    End Sub
0
kdeutschAuthor Commented:
All,
Ok I got it to work to filter, but I the gird doe not change as it filters.
 Protected Sub ddlTasks_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlTasks.SelectedIndexChanged
        pnlGrid.Visible = True
        FillGrid()
    End Sub

    Protected Sub txtFindSoldier_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFindSoldier.TextChanged
        myDataTable = CType(Session("mydataTable"), DataTable)
        myDataTable.DefaultView.RowFilter = "strFullname like '%" & txtFindSoldier.Text & "&'"

        FillGrid()
    End Sub

    Private Sub FillGrid()
        Dim srp As Integer = ddlSrpEvent.SelectedValue
        Dim cat As Integer = ddlTasks.SelectedValue
        Dim theCounter As Integer
        Dim SqlWhere As String

        'If HFID.Value = "" Then
        '    SqlWhere = ""
        'Else
        '    SqlWhere = "AND ed.intPersonnelID = '" & HFID.Value & "'"
        'End If

        sql = "Select ed.intDataId, q.strTask, ed.intAnswer as Answer, ed.strData, ed.strRemarks, strDocDate, w.strFullName From tblSRPEventData as ed INNER JOIN tblSRPQuestion as q on " _
            & "q.intQuestionId = ed.intQuestionId INNER JOIN " _
            & "tblQuestionCategory as qc on qc.intCategoryId = q.intCategoryID INNER JOIN WORSDotNet.dbo.tblUser as w on w.strSSN = cast(ed.intPersonnelID as varchar) Where q.intcategoryId = " & cat & " and " _
            & "intEventId = " & srp & " and intAnswer = 1 Order by w.strFullname"

        myDataTable = New DataTable
        myDataTable = getData(sql)
        Session("myDataTable") = myDataTable
        myGridview.DataSource = myDataTable
        myGridview.DataBind()

        For theCounter = 0 To myGridview.Rows.Count - 1

        Next

        lblCount.Text = theCounter & " Records"

        'Wipe the HFID for onload events
        HFID.Value = Nothing
        txtFindSoldier.Text = String.Empty
    End Sub
0
kdeutschAuthor Commented:
No response, to finish out, changed to another method.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.