filter dataset

G

Guest

I have a page that passing data to a new page via a querystring, on the other
page i need to fitler the dataset and populate a datagrid based on the items
being passed via the querystriing. Does anyone have any suggestions on how to
get this working? Right now its only getting the last item in the query
string and filter on that.

example:
Querystring looks like this.
cars.aspx?make=Chevy&model=Corvette
I need only data where make = chevy and model= corvette only and then
poluate the datagrid.
??
 
L

Lucas Tam

I have a page that passing data to a new page via a querystring, on
the other page i need to fitler the dataset and populate a datagrid
based on the items being passed via the querystriing. Does anyone have
any suggestions on how to get this working? Right now its only getting
the last item in the query string and filter on that.

example:
Querystring looks like this.
cars.aspx?make=Chevy&model=Corvette
I need only data where make = chevy and model= corvette only and then
poluate the datagrid.

You can apply a dataview:

Dataset.table(0).Defaultview.RowFilter ="make=Chevy&model=Corvette"

For your datagrid, you would bind to:

DataGrid.DataSource = Dataset.table(0).Defaultview
Datagrid.Databind

However, if the grid is static, it may make more sense to filter the
query rather than the datagrid.
 
G

Guest

here is my current code and it only shows the last item selected.
For Each car In carList
dvCars= New DataView
'Response.Write(Cars& "<br>") 'see how the string is being passed
With dvCars
.Table = dsCarList.Tables(0)
.RowFilter = "CarMake=" & "'" & make & "'"
End With
Next
dlCars.DataSource = dvCars
dlCars.DataBind()
 
L

Lucas Tam

here is my current code and it only shows the last item selected.
For Each car In carList
dvCars= New DataView
'Response.Write(Cars& "<br>") 'see how the string is being
passed With dvCars
.Table = dsCarList.Tables(0)
.RowFilter = "CarMake=" & "'" & make & "'"
End With
Next
dlCars.DataSource = dvCars
dlCars.DataBind()


You don't need to apply so many dataviews.

Your .RowFilter should look like "Carmake=1 OR carmake=2 OR carmake=3" etc
etc. There is no need to create separate dataviews (unless you want to...)
 
G

Guest

what do you mean by "There is no need to create separate dataviews"
I'm only creating one. The rowfilter does work if I only pass on value to
it, but if pass more then one it doesn't work.
I'm passing the values with | to seperate them, then splitting the string at
|.
if i remove the | and only do 1 it works, if I keep | in there it doesn't
work even with passing 1 value in the query string

"
 
L

Lucas Tam

what do you mean by "There is no need to create separate dataviews"
I'm only creating one. The rowfilter does work if I only pass on value
to it, but if pass more then one it doesn't work.
I'm passing the values with | to seperate them, then splitting the
string at
|.
if i remove the | and only do 1 it works, if I keep | in there it
doesn't work even with passing 1 value in the query string


In your code you go:
For Each car In carList
dvCars= New DataView



I believe a new dataview will be created for each car in carList. Do you
want one large dataview?

As for multiple conditions ... run the debugger or reponse.write the
..RowFilter string. See if it is formatted correctly.

You also need to have operators between each condition such as
AND/OR/NOT etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top