473,386 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Filter Records

Hello,

I have a GridView and I need to display only the records which field
in datasource named "visible" is set to true.

How can I do this?

Thanks,
Miguel

Mar 8 '07 #1
5 1525
Create a DataView with RowFilter property set to "'visible'=true" and
databind the gridview to it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"shapper" <md*****@gmail.comwrote in message
news:11*********************@h3g2000cwc.googlegrou ps.com...
Hello,

I have a GridView and I need to display only the records which field
in datasource named "visible" is set to true.

How can I do this?

Thanks,
Miguel

Mar 8 '07 #2
On Mar 8, 12:23 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
Create a DataView with RowFilter property set to "'visible'=true" and
databind the gridview to it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

"shapper" <mdmo...@gmail.comwrote in message

news:11*********************@h3g2000cwc.googlegrou ps.com...


Hello,
I have a GridView and I need to display only the records which field
in datasource named "visible" is set to true.
How can I do this?
Thanks,
Miguel
And can I create two data views and use one or the other?

I just know how to use the default view

I am creating my data views as follows:
Dim dvLevels As New DataView(dtLevels, "LevelSubscribed = False",
"LevelName", DataViewRowState.CurrentRows)

Thanks,
Miguel

Mar 8 '07 #3
Sure you can. Like you do in the code
Dim dvLevels As New DataView(dtLevels, "LevelSubscribed = False",
"LevelName", DataViewRowState.CurrentRows)
Just create another one similarly and databind to whatever is needed.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"shapper" <md*****@gmail.comwrote in message
news:11*********************@p10g2000cwp.googlegro ups.com...
On Mar 8, 12:23 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
>Create a DataView with RowFilter property set to "'visible'=true" and
databind the gridview to it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

"shapper" <mdmo...@gmail.comwrote in message

news:11*********************@h3g2000cwc.googlegro ups.com...


Hello,
I have a GridView and I need to display only the records which field
in datasource named "visible" is set to true.
How can I do this?
Thanks,
Miguel

And can I create two data views and use one or the other?

I just know how to use the default view

I am creating my data views as follows:
Dim dvLevels As New DataView(dtLevels, "LevelSubscribed = False",
"LevelName", DataViewRowState.CurrentRows)

Thanks,
Miguel

Mar 8 '07 #4
Shapper-

You mentioned that you are comfortable with the DefaultView DataView. As
Eilyahu mentioned, you can create additional DataViews as needed within your
applications. See below:

DataTable testData = GenFakeData(); // Generate our fake data.
testData.DefaultView.RowFilter = "Visible=true"; // Filter on our visible
column == true.
testGridView.DataSource = testData.DefaultView; // Set our GridView's datasource
to our filtered view.
testGridView.DataBind(); // bind.

This returns:

Group, Value, Visible
1, 3, true
1, 4, true
1, 5, true
2, 3, true
2, 4, true
2, 5, true

DataTable testData2 = GenFakeData(); // Generate our fake data.
DataView dv = new DataView(testData2); // Create a new dataview based on
our datatable.
dv.RowFilter = "Visible=false"; // Filter on our visible column == false.
testGridView2.DataSource = dv; // Set our GridView's datasource to our newly
created view.
testGridView2.DataBind(); // bind.

This returns:

Group, Value, Visible
1, 1, false
1, 2, false
2, 1, false
2, 2, false

HTH.

-dl
---
David Longnecker
Web Developer
http://blog.tiredstudent.com
On Mar 8, 12:23 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
>Create a DataView with RowFilter property set to "'visible'=true" and
databind the gridview to it.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
"shapper" <mdmo...@gmail.comwrote in message

news:11*********************@h3g2000cwc.googlegro ups.com...
>>Hello,

I have a GridView and I need to display only the records which field
in datasource named "visible" is set to true.

How can I do this?

Thanks,
Miguel
And can I create two data views and use one or the other?

I just know how to use the default view

I am creating my data views as follows:
Dim dvLevels As New DataView(dtLevels, "LevelSubscribed = False",
"LevelName", DataViewRowState.CurrentRows)
Thanks,
Miguel

Mar 8 '07 #5
On Mar 8, 1:08 pm, David Longnecker <dlongnec...@community.nospam>
wrote:
Shapper-

You mentioned that you are comfortable with the DefaultView DataView. As
Eilyahu mentioned, you can create additional DataViews as needed within your
applications. See below:

DataTable testData = GenFakeData(); // Generate our fake data.
testData.DefaultView.RowFilter = "Visible=true"; // Filter on our visible
column == true.
testGridView.DataSource = testData.DefaultView; // Set our GridView's datasource
to our filtered view.
testGridView.DataBind(); // bind.

This returns:

Group, Value, Visible
1, 3, true
1, 4, true
1, 5, true
2, 3, true
2, 4, true
2, 5, true

DataTable testData2 = GenFakeData(); // Generate our fake data.
DataView dv = new DataView(testData2); // Create a new dataview based on
our datatable.
dv.RowFilter = "Visible=false"; // Filter on our visible column == false.
testGridView2.DataSource = dv; // Set our GridView's datasource to our newly
created view.
testGridView2.DataBind(); // bind.

This returns:

Group, Value, Visible
1, 1, false
1, 2, false
2, 1, false
2, 2, false

HTH.

-dl

---
David Longnecker
Web Developerhttp://blog.tiredstudent.com
On Mar 8, 12:23 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
Create a DataView with RowFilter property set to "'visible'=true" and
databind the gridview to it.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
"shapper" <mdmo...@gmail.comwrote in message
>news:11*********************@h3g2000cwc.googlegro ups.com...
>Hello,
>I have a GridView and I need to display only the records which field
in datasource named "visible" is set to true.
>How can I do this?
>Thanks,
Miguel
And can I create two data views and use one or the other?
I just know how to use the default view
I am creating my data views as follows:
Dim dvLevels As New DataView(dtLevels, "LevelSubscribed = False",
"LevelName", DataViewRowState.CurrentRows)
Thanks,
Miguel
Yes, I know. I had that.

My question was if I could access each view as follows:

DataTable.MyNewView

Instead of:

DataTable.DefaultView

Anyway, I got this now ...

Thanks,
Miguel

Mar 8 '07 #6

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

Similar topics

2
by: Salad | last post by:
I have a log file with a list of records. The log file can be unfiltered or filtered. I have a command button to call a data entry form from the log. At first I was only going to present the...
4
by: Nhmiller | last post by:
This is directly from Access' Help: "About designing a query When you open a query in Design view, or open a form, report, or datasheet and show the Advanced Filter/Sort window (Advanced...
16
by: Nhmiller | last post by:
I already have a report designed under Reports. When I use filtering in Forms or Tables, I see no way to select that filtered list when I am in Reports, and there appears to be no way to do the...
2
by: cefrancke | last post by:
I have a form (no underlying record set) that has two separate sub-forms on it. Each sub-form has data from two different tables. Above each sub-form there is one unbound combo box with a SQL...
3
by: Stewart | last post by:
Hi all! My (relatively small) database holds data on staff members and the projects (services) that they are assigned to. In my form frmStaff, I have a list of staff members - it is a...
3
by: dhowell | last post by:
In reading some of the posts on this group, it appears as though it is not strait forward at all to filter a form, which has subforms, by criteria which are either on subforms or span more than one...
5
by: Ron S | last post by:
After days of searching I finally an example that would work with my application, the only problem is after entering all of the code it is not working. Would someone be kind enough to take a look at...
6
by: Sheree | last post by:
I have VBA code (Access 2003) like this: Private Sub SubName() rs.Filter = "" x = msgbox("Filter cleared. Number of records: " & rs.RecordCount") rs.Filter = "SELECT * from " rs.Sort = "Field1...
0
by: diogenes | last post by:
"Rick Brandt" <rickbrandt2@hotmail.comwrote in news:bPnKj.456$%41.325 @nlpi064.nbdc.sbc.com: I used this approach, and it works a treat! ID In(SELECT Order_ID FROM orderitems WHERE NAME =...
1
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.