Filter Data in a datagrid using variables.

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

running32Asked:
Who is Participating?
 
DhaestConnect With a Mentor Commented:
The columnnames don't have to be between brackets.

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


DataGrid Filter
http://www.codeproject.com/KB/grid/GridFilter.aspx

Filter and Sort the DataGrid Using a DataView...
http://www.dotnetjohn.com/articles.aspx?articleid=31
0
 
running32Author Commented:
Prefect.  Thanks
0
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.

All Courses

From novice to tech pro — start learning today.