473,327 Members | 2,090 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,327 software developers and data experts.

Filter Datagrid

How can I place a filter on my datagrid only to view
specific records ?

The query In SQL would be:

SELECT *
FROM Orders
WHERE dispatched = X

The filter will be applied on the click event of a set of
radio buttons
Nov 20 '05 #1
8 1830
if your basing your datgrid off a dataset (probably) you can use the .Select
method

where it would be everything AFTER your WHERE clause.

you can also use a dataview which does the same thing except you use the
RowFilter property and it takes care of error handling.

Which is nice.

so you can do. mydataset.tables(0).Select("dispachted = '" & x & "'")

or

myDv.rowFilter = "dispatched = '" & x & "'"

"Smudger" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
How can I place a filter on my datagrid only to view
specific records ?

The query In SQL would be:

SELECT *
FROM Orders
WHERE dispatched = X

The filter will be applied on the click event of a set of
radio buttons

Nov 20 '05 #2
it seems that you are trying to use the variable x out of scope (it isn't
declared correctly to use it there)

try putting the private declaration (private x as string) at the top of your
form
if you want to use yes (text) you have to put it betueen "" to make it a
string
mydataset.tables(0).Select("dispatched = '" & "yes" & "'") or mydataset.tables(0).Select("dispatched = 'yes'")
hope it helps

eric

"Smudger" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl... Using:

mydataset.tables(0).Select("dispatched = '" & x & "'")

Highlights the x in the debugger with the error:
System.Windows.Forms.Control.x is not availble in this
context because it is private

When I subsitute the x for my criteria which is 'yes' the
yes is underlined with the error:
Name yes is not declared

any ideas what I could be doing wrong, the datagrid is
being fed by a dataset

Nov 20 '05 #3
ok Eric, this compiles error free but how do I display
the results of the query in my initial datagrid

I tried to fill the adapter again immediately after the
query but it doesn't display the results
Nov 20 '05 #4
Cor
Hi Smudger

The select creates an array of datarows.

dim myarray() as datarow = ds........... select

You can use it, but I think it is more easy in your case to use the dataview
with row filter as CJ did give you.

This is copied from MSDN
Private Sub MakeDataView()
Dim dv As DataView
dv = New DataView
With dv
.Table = DataSet1.Tables("Suppliers")
.AllowDelete = True
.AllowEdit = True
.AllowNew = True
.RowFilter = "City = 'Berlin'"
.RowStateFilter = DataViewRowState.ModifiedCurrent
.Sort = "CompanyName DESC"
End With

' Simple bind to a TextBox control
Text1.DataBindings.Add("Text", dv, "CompanyName")
End Sub

I hope this helps?

Cor
Nov 20 '05 #5
Thanks eric, couldn't get access to newsgroups for awhile so couldn't reply.
Thanks for covering. =)

-CJ
"EricJ" <ericRéMo**@ThiSomnipack.be> wrote in message
news:Ox****************@TK2MSFTNGP10.phx.gbl...
it seems that you are trying to use the variable x out of scope (it isn't
declared correctly to use it there)

try putting the private declaration (private x as string) at the top of your form
if you want to use yes (text) you have to put it betueen "" to make it a
string
mydataset.tables(0).Select("dispatched = '" & "yes" & "'")

or
mydataset.tables(0).Select("dispatched = 'yes'")


hope it helps

eric

"Smudger" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...
Using:

mydataset.tables(0).Select("dispatched = '" & x & "'")

Highlights the x in the debugger with the error:
System.Windows.Forms.Control.x is not availble in this
context because it is private

When I subsitute the x for my criteria which is 'yes' the
yes is underlined with the error:
Name yes is not declared

any ideas what I could be doing wrong, the datagrid is
being fed by a dataset


Nov 20 '05 #6
x Marks The Spot

;-)

----------------------------------------------------------------

Cor wrote:
Hi Smudger

The select creates an array of datarows.

dim myarray() as datarow = ds........... select

You can use it, but I think it is more easy in your case to use the
dataview with row filter as CJ did give you.

This is copied from MSDN
Private Sub MakeDataView()
Dim dv As DataView
dv = New DataView
With dv
.Table = DataSet1.Tables("Suppliers")
.AllowDelete = True
.AllowEdit = True
.AllowNew = True
.RowFilter = "City = 'Berlin'"
.RowStateFilter = DataViewRowState.ModifiedCurrent
.Sort = "CompanyName DESC"
End With

' Simple bind to a TextBox control
Text1.DataBindings.Add("Text", dv, "CompanyName")
End Sub

I hope this helps?

Cor


Regards - OHM# On**********@BTInternet.com
Nov 20 '05 #7
Your still not doing something right then, the datagrid automatically
updates based on the change within (caused by a Select method which raises
an event to the grid (or other bound controls) of the change

either a, your expression isn't showing any results that match, or b, your
filter expression isn't any good...

Are you sure your selecting the right tables/dataset/dataview? and is your
binding context set correctly, I mess that up all the time.

-CJ
"Smudger" <an*******@discussions.microsoft.com> wrote in message
news:14*****************************@phx.gbl...
ok Eric, this compiles error free but how do I display
the results of the query in my initial datagrid

I tried to fill the adapter again immediately after the
query but it doesn't display the results

Nov 20 '05 #8
mine are acting up 2 i still don't c the post from smudger (the one i
replied 2) on this news server (news.skynet.be) but it is on
new.microsoft.com, strange

eric

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:vt************@corp.supernews.com...
Thanks eric, couldn't get access to newsgroups for awhile so couldn't reply. Thanks for covering. =)

-CJ
"EricJ" <ericRéMo**@ThiSomnipack.be> wrote in message
news:Ox****************@TK2MSFTNGP10.phx.gbl...
it seems that you are trying to use the variable x out of scope (it isn't declared correctly to use it there)

try putting the private declaration (private x as string) at the top of

your
form
if you want to use yes (text) you have to put it betueen "" to make it a
string
mydataset.tables(0).Select("dispatched = '" & "yes" & "'")

or
mydataset.tables(0).Select("dispatched = 'yes'")


hope it helps

eric

"Smudger" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...
Using:

mydataset.tables(0).Select("dispatched = '" & x & "'")

Highlights the x in the debugger with the error:
System.Windows.Forms.Control.x is not availble in this
context because it is private

When I subsitute the x for my criteria which is 'yes' the
yes is underlined with the error:
Name yes is not declared

any ideas what I could be doing wrong, the datagrid is
being fed by a dataset



Nov 20 '05 #9

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

Similar topics

1
by: Peter | last post by:
In this topic "Walkthrough: Using a DataGrid Web Control to Read and Write Data" updates/edits of a table are covered for all data and column(s). However no topic or section dedicated to explain...
1
by: Mike C | last post by:
I have a datagrid that outputs sales data like this: Customer Month Sales Acme Corp Jan 1,345 Acme Corp Feb 2,567 I'm trying to make it look like this: Customer ...
3
by: Dan V. | last post by:
How can I use real SQL on a DataTable? i.e. not array of rows using a filter... as in DataTable.Select. I read at : microsoft.public.dotnet.framework.adonet "As others have posted: There is no...
3
by: Pedor | last post by:
I want to display only data in the datagrid for specific records having a common or identical data in a column. How do you do this programmaticaly using combination of the datagrid object,...
1
by: RockNRoll | last post by:
I'm new to ASP.NET and need to filter a datagrid based on a textbox value. I have a working datagrid and would like the WHERE part of my SQL statement to call the value of a textbox and refresh...
2
by: AJ | last post by:
Hi all, An easy question! I have a datagrid that can needs to provide filter functionality. I have three controls above the grid (txtSearch,ddlSearchBy,btnSearch) btnSearch calls...
3
by: jason | last post by:
I'll try to explain in detail what it is I'm struggling with. I created a SQL database with one table called CallSheet which contains the following columns: Caller ID: <--Primary Key, auto...
9
by: thebison | last post by:
Hi all, I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my...
2
by: amir | last post by:
How can I filter my database in Multiple way, I mean that I wana to filter st. like this: sm* *th* *er Please Help me on this matter Amir
3
by: amir | last post by:
How can I filter again my previous filtered records, I mean when I filter an entire I can filter again and again the filtered data. Many thanks for your help. Amir
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.