472,328 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Selecting specific columns from a dataview?

Hello,

I have a complete table within a dataset.

I want a dataview to show particular filtered data - works great with
the dv.rowfilter.

But can I display only certain columns that are filtered?

Right now in my rowfilter I have something like this:

dv.RowFilter = "Title like '%Whales%' OR Genus like 'Megaptera'"

This prints all of the fields in the table (30). I want to show only 4
fields

I cannot get a away with:

dv.rowfilter = "select Title, Genus, [Climate ID], Endangered from
Animals where Title like '%Whales%' OR Genus like 'Megaptera'"

I get this error: Missing operand after 'Title' operator

*Note "Climate ID" is the name of a column (yes it has a space in it so
I bracketed it).

So in row filter you cannot put in a full sql statement....

The dataset cannot be changed.

Anyway to pull specific columns from this table?

Thanks,

Tmuld.

Nov 21 '05 #1
4 16158
Hi,

Add a tablestyle to your datagrid.

http://msdn.microsoft.com/library/de...stdatagrid.asp

http://msdn.microsoft.com/library/de...asicprimer.asp

Ken
--------------------
"Tmuld" <tm******@spliced.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hello,

I have a complete table within a dataset.

I want a dataview to show particular filtered data - works great with
the dv.rowfilter.

But can I display only certain columns that are filtered?

Right now in my rowfilter I have something like this:

dv.RowFilter = "Title like '%Whales%' OR Genus like 'Megaptera'"

This prints all of the fields in the table (30). I want to show only 4
fields

I cannot get a away with:

dv.rowfilter = "select Title, Genus, [Climate ID], Endangered from
Animals where Title like '%Whales%' OR Genus like 'Megaptera'"

I get this error: Missing operand after 'Title' operator

*Note "Climate ID" is the name of a column (yes it has a space in it so
I bracketed it).

So in row filter you cannot put in a full sql statement....

The dataset cannot be changed.

Anyway to pull specific columns from this table?

Thanks,

Tmuld.
Nov 21 '05 #2
Tmuld,

No you cannot create a dataview with less columns than its underlying
datatable.

A dataview is only a view on a dataset. Nothing more. It has a rowfilter
however not a columnfilter.

So you have to do it in your controls. What can with the standard controls
only be a problem for the datagrid. When it is a winform, look than at the
links Ken has provided, because to do it is a part of the datagrid..

I hope this helps,

Cor
Nov 21 '05 #3
Since I am doing a .ASP project the information Ken quoted will not
work right?

How would I do it from the controls? Example or link?

Thanks again?

Nov 21 '05 #4
Tmuld,

The samples are all using HTML. I made one without that and all in VBNet
code.

\\\Needs a datagrid on a webform
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim DS1 As New DataSet
Dim dT As New DataTable("Table Name")
dT.Columns.Add("Col1", GetType(System.String))
dT.Columns.Add("Col2", GetType(System.String))
dT.LoadDataRow(New Object() {"Tmuld", "Cor"}, True)
DS1.Tables.Add(dT)
DataGrid1.DataSource = DS1.Tables(0)
Dim b1 As New BoundColumn
Dim b2 As New BoundColumn
b1.DataField = "Col1"
b2.DataField = "Col2"
b1.HeaderText = "Question"
b2.HeaderText = "Answer"
DataGrid1.Columns.Add(b1)
DataGrid1.Columns.Add(b2)
DataGrid1.AutoGenerateColumns = False
DataGrid1.DataBind()
End Sub
///

I hope this helps a little bit?

Cor

I hope this helps,

Cor
Nov 21 '05 #5

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

Similar topics

6
by: aaa | last post by:
Hi I am trying to create a read-only DataGrid that would always have current row selected. Currently, I am using method: public void...
5
by: Dave | last post by:
Hi all, Apologies if this is the wrong group. I have done a search on google but my keywords are probably no good. What I want to do is to...
6
by: aaj | last post by:
Hi all I use a data adapter to read numerous tables in to a dataset. The dataset holds tables which in turn holds full details of the records...
2
by: Karl Napp | last post by:
Hi NG, how to make a DataView show only selected COLUMNS? E.g: DataTable table // is already in memory and has two columns: "id" and "value"...
2
by: Patrick.O.Ige | last post by:
I have some boolean value(1 or 0 ) in a table and i want a databinded CheckBoxList to present the selected values on the page.. With CheckBox i...
5
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...
11
by: Ron L | last post by:
I have a data table that lists a series of items in my database. In my user form, I want the user to be able to filter by a number of criteria...
0
by: | last post by:
I am testing the following piece of code: Is it possible to list the row number containing the checked box? After checking the desired box, I would...
1
by: Richard Jonker | last post by:
Hi, I'm developing a webpage with a dataview. The data is retrieved from a database view. The columns in the dataview are created dynamically via...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.