473,657 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Dataview limited to certain columns from datatable

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
..defaultdatavi ew method of the table (eg dv=ds.tables(0) .defaultdatavie w)

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
Nov 23 '05 #1
4 4831
Have you tried using the RowFilter method of the dataview to limit the data
after the fact?

"Simon Verona" <no****@nomail. zzz> wrote in message
news:Oc******** ******@tk2msftn gp13.phx.gbl...
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
.defaultdatavie w method of the table (eg dv=ds.tables(0) .defaultdatavie w)

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

Nov 23 '05 #2
Simon Verona wrote:
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
.defaultdatavie w method of the table (eg dv=ds.tables(0) .defaultdatavie w)

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
Nov 23 '05 #3
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
Nov 23 '05 #4
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
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
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

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
17607
by: John Smith | last post by:
Hey folks, I have a Global DataSet which I use across my application. I use a DataView to give me the data that I want in a certain instance. Is there a way I can create the DataView so that it has only some of the columns of the DataSet (i.e. not all of them)? If not, can I reorder the columns? Like, can I specify that I want "myCol" to be the second column?
1
1180
by: Phil Townsend | last post by:
I have a dataview that is generated from a dataset which gets its data from an xml file. I would like to use the dataview to include only certain columns in the result set. The xml file contains 7 seven columns and I need my dataview to contain only five of them. Is the dataview the right control to do this? Thanks... *** Sent via Developersdex http://www.developersdex.com ***
6
12900
by: Alpha | last post by:
I have a listbox with datasource from a dataview. When a user selects a different item in a combobox then I need to refresh the listbox to the appropriate listing based on that combobox's selected value which is included in the listbox's filtering statement. Is the only way to do this is to dispose the dataview and then create a new one and then bind it to the listbox? Is there a better way than this? Thanks, Alpha
8
3889
by: Dave Hagerich | last post by:
I'm using a DataGrid with a DataSet and I'm trying to filter the data being displayed, using the following code as a test: DataView theView = new DataView(theDataSet.Tables); theView.RowFilter = "'Record ID' = '0'"; theView.RowStateFilter = DataViewRowState.ModifiedCurrent; Debug.WriteLine(string.Format("RowFilter = {0}", theView.RowFilter)); RecordDataGrid.DataSource = theView; RecordDataGrid.DataBind();
13
2095
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is the confusion......... I thought that the DataView is the view from the dataset, but it seems that the dataview has the records that are in the datagrid, because everytime I search for a record that I know is NOT in the dataset, it finds it. I...
5
8824
by: David Wender | last post by:
I want to create a dataview with a sort on multiple columns. However, when I use FindRows, I only want to search some of the columns, not all. Is this possible? I have not been able to make it happen. Dim objKeys(2) as Object objKeys(0) = "CL" objKeys(2) = 4000 Dim posView As DataView = New DataView(posDS.Tables("Positions"), _
0
1835
by: Nathan Franklin | last post by:
Hello Guys, I have been trying to work this our for so long, but I just can't seem to find the answer. I am loading a datatable from a an access database using an oledbdataadapter. I then assign the datatable.dataview to my datagrid.datasource member so it will display my results.. I need to give the user an option to change the order of this data, I have a
6
16735
by: Nick | last post by:
I have a code that returns data in IList. My webGrid doesn't allow me to sort with IList returned, it say it only suports DataView, DataTable and DataSet, not IEnumerable. I don't know how to return the DataSet type when using the following code: ======== this is my interface ====================== namespace WareHouse.DataLayer.DataObjects { /// <summary> /// Defines methods to access categories and products.
3
2430
by: hzgt9b | last post by:
Using VS2005, VB.NET, I know that I can use a DataView to constrain what rows are "seen" from the underlying datatable - is it also possible to use a DataView to constrain what columns/attributes "seen" from the underlying datatable? If so, can you point me to an example. Thanks for your attention to this...
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.