DataView.Rowfilter question

  • Thread starter Thread starter KC
  • Start date Start date
K

KC

For a DataView.Rowfilter can I use more than one expression? I want to
filter out two different things.

For example can I take:

dv.RowFilter = "MTX <> 'Customer Forcast'"

and

dv.RowFilter = "MTX <> 'Actual vs. Forcast'"

and combine them into one statement?

dv.RowFilter = "MTX <> 'Customer Forcast' And MTX <> 'Actual vs. Forcast'"

Is this format correct? If not, what's the format?
 
Yea, that was it, thanks.

I'm trying stuff out with this DataView thing. It doesn't seem like you can
filter columns in a DataView, is that right? I had the impression it was
like creating a View in oracle or sql server - you decide what columns and
rows are shown.

Ken

Jay B. Harlow said:
Ken,
dv.RowFilter = "MTX <> 'Customer Forcast' And MTX <> 'Actual vs. Forcast'"
Is this format correct? If not, what's the format?
Yes that is the correct format, did you try it? Are you having problems with
that format?

For information on expressions in the DataSet object model see the
DataColumn.Expression help topic.

http://msdn.microsoft.com/library/d...fsystemdatadatacolumnclassexpressiontopic.asp

Hope this helps
Jay
 
Ken,
You can filter the rows you see with a DataView, however you will always see
all the rows.

David Sceppa explains how a DataView works and how to use it in his book
"Microsoft ADO.NET - Core Reference" from MS Press.

If you are doing a lot with ADO.NET I strongly recommend Sceppa's book,
which is a good tutorial on ADO.NET as well as a good desk reference once
you know ADO.NET.

Hope this helps
Jay

KC said:
Yea, that was it, thanks.

I'm trying stuff out with this DataView thing. It doesn't seem like you can
filter columns in a DataView, is that right? I had the impression it was
like creating a View in oracle or sql server - you decide what columns and
rows are shown.

Ken

Jay B. Harlow said:
Ken,
Yes that is the correct format, did you try it? Are you having problems with
that format?

For information on expressions in the DataSet object model see the
DataColumn.Expression help topic.
http://msdn.microsoft.com/library/d...fsystemdatadatacolumnclassexpressiontopic.asp
 
Doh!
You can filter the rows you see with a DataView, however you will always see
all the rows.

That should read:

You can filter the rows you see with a DataView, however you will always see
all the columns.

Jay
 
Hi Jay,
You can filter the rows you see with a DataView, however you will always
see all the columns.

I saw it, however had no anwser because the columns are only visible when a
binded control is used that shows default all columns. (datagrid,
crystalreports, vendors controls).

And than are in those controls columns filters to select the right one.

It is not as a kind of SQL view.

Difficult problem how to tell it in the right context.

Maybe it can be like this.

When you using a rowfilter, than only the not filtered rows are available in
the dataview, however all the columns.

Cor
 
Cor,
Thank you for the information, I was simply correcting a typo I made.
I saw it, however had no anwser because the columns are only visible when
a
All the columns are "visible" from code via the DataRowView.Item property
also!

It really depends on how you translate "visible".

I understand KC is effectively asking for a "ColumnFilter" property that
accepts a comma separated list of fields, so only those fields are "seen"
via the DataRowView.Item property. There is no such property.

If however KC binding the view to a DataGrid, the DataGrid itself has a
column collection avaible to control which columns are shown.

Hope this helps
Jay
 
Hi KC,

I understood that you where looking for something like this.
Most code is the creating of the sampleTable.

I hope this helps

Cor
\\\
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Makesampletable()
Dim mycolumns() As String = {"1", "3", "7", "9"}
myproc(mycolumns)
End Sub
Private Sub myproc(ByVal mycolumns() As String)
Dim ts As New DataGridTableStyle
ts.MappingName = "Pieter"
For Each mycolumn As String In mycolumns
Dim column As New DataGridTextBoxColumn
ts.GridColumnStyles.Add(column)
DataGrid1.TableStyles.Add(ts)
column.MappingName = mycolumn
column.HeaderText = mycolumn
Next
DataGrid1.TableStyles.Add(ts)
End Sub
Private Sub Makesampletable()
Dim dt As New DataTable("Pieter")
For i As Integer = 0 To 9
dt.Columns.Add(i.ToString)
Next
For y As Integer = 1 To 9
Dim dr As DataRow = dt.NewRow
For i As Integer = 0 To 9
dr(i) = i.tostring
Next
dt.Rows.Add(dr)
Next
DataGrid1.DataSource = dt
End Sub
////
 
Back
Top