JeepGeekin
asked on
Filter with Functions
I have a date column that I want to apply a filter to (using the dataview rowfilter). My problem is that I need to filter it by just the Year of that column, not the whole date.
Something like this is what I am currently working with:
Dim dv As New DataView(ds.Tables(0))
dv.RowFilter = "Year(payment_date) = " & text1.text.trim
GridView1.DataSource = dv
GridView1.DataBind()
This gives me the error: The expression contains undefined function call Year().
Is there a way to do this without altering the dataset possibly using date functions?
Something like this is what I am currently working with:
Dim dv As New DataView(ds.Tables(0))
dv.RowFilter = "Year(payment_date) = " & text1.text.trim
GridView1.DataSource = dv
GridView1.DataBind()
This gives me the error: The expression contains undefined function call Year().
Is there a way to do this without altering the dataset possibly using date functions?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Great idea! Thanks! Worked perfectly.
...also, thanks BriCrow, but I was asked to avoid altering the sql since multiple people use it.
...also, thanks BriCrow, but I was asked to avoid altering the sql since multiple people use it.
"SELECT ..., Year(payment_date) as payment_year, ... FROM ..."
dim dv as new dataview(ds.tables(0))
dv.rowfilter = "payment_year = " + text1.text.trim
you will probalby want to add datagridcolumns to your gridview so that the payment_year isn't included.