• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

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

0
running32
Asked:
running32
1 Solution
 
DhaestCommented:
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now