Filter Data in a datagrid using variables.

Posted on 2008-11-12
Last Modified: 2012-06-27
when i click on the grid slocation has the correct name and scolumnname has the correct name but the filter brings back no records.  what am I doing wrong wth these two statements please?  Thank you

 DspaBilling1.Tables("tblPAVoucher").DefaultView.RowFilter = "'" & scolumnname & "' = '" & sLocation & "'"
 dv.RowFilter = "'" & scolumnname & "' = '" & sLocation & "'"
  Dim pt = New Point(e.X, e.Y)

                Dim hti As DataGrid.HitTestInfo = DataGrid1.HitTest(pt)

                If hti.Type = DataGrid.HitTestType.Cell Then

                    DataGrid1.CurrentCell = New DataGridCell(hti.Row, hti.Column)

                    Dim sLocation As String

                    Dim scolumnname

                    scolumnname = DataGrid1.TableStyles(0).GridColumnStyles(hti.Column).MappingName()

                    ' sLocation = DataGrid1.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember).Current.Row.Item(scolumnname)

                    sLocation = DataGrid1.Item(hti.Row, hti.Column)

                    DspaBilling1.Tables("tblPAVoucher").DefaultView.RowFilter = "'" & scolumnname & "' = '" & sLocation & "'"

                    dv.RowFilter = "'" & scolumnname & "' = '" & sLocation & "'"

                    DataGrid1.DataSource = dv

                End If

Open in new window

Question by:running32
    LVL 53

    Accepted Solution

    The columnnames don't have to be between brackets.

    dv.RowFilter = scolumnname & " = '" & sLocation & "'"

    DataGrid Filter

    Filter and Sort the DataGrid Using a DataView...

    Author Comment

    Prefect.  Thanks

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now