Creating Dataview limited to certain columns from datatable

  • Thread starter Thread starter Simon Verona
  • Start date Start date
S

Simon Verona

Normally Google is my friend, but I can't seem to work this one out. I'm
sure it's really simple as well.

I normally create a dataview from a table within a dataset using the
..defaultdataview method of the table (eg dv=ds.tables(0).defaultdataview)

I want to create a dataview that is limited to only certain columns of the
datatable.

Anybody got a quick example to get me going?

Thanks in advance
Simon
 
Have you tried using the RowFilter method of the dataview to limit the data
after the fact?
 
Simon said:
Normally Google is my friend, but I can't seem to work this one out. I'm
sure it's really simple as well.

I normally create a dataview from a table within a dataset using the
.defaultdataview method of the table (eg dv=ds.tables(0).defaultdataview)

I want to create a dataview that is limited to only certain columns of the
datatable.

Anybody got a quick example to get me going?

Thanks in advance
Simon

I guess my question is why you want to do this?

The dataview is just a filtered view of the table. It limits what rows
you see. Whatever you are using to display the data (datagrid?) should
be limiting the number of columns you see. The data is not copied when
you use a dataview, it is still pointing to the same datatable and
therefore needs the same structure.

Chris
 
Simon,

It is as Chris write, however I have seen this question more, therefore I am
curious why you ask this?

(You can hide a column of a datatable with the columnmapping, however it is
than for all dataviews)

Cor
 
You are correct, I can alter the display using the datagrid that I'm using
(it's actually Component One's truedbgrid that I'm using).

Just was thinking that it might be easier and quicker to remove the column
from the dataview that I'm creating - this is a view only grid so there will
be no updating/deleting etc.

I found the columnmapping property and I'm experimenting with that,
otherwise I'll choose the columns on the datagrid itself.

Thanks for the thoughts
Simon
 
Back
Top