bitwise comparator

R

Random

I need to apply a filterparameter to a result set in my GridView based on
the selection in a DropDownList control. I want to use the integer
SelectedValue property of the DropDownList to filter the grid based on a
bitwise comparator. I could just do this in my query select statement, but
I want to cache the overall result set for faster subquery operations.

In T-SQL the bitwise comparator is the ampersand (&), but I am getting an
invalid character exception. Does anyone here know what the .NET compiler
might accept for this type of operation?
 
H

Hans Kesting

Random said:
I need to apply a filterparameter to a result set in my GridView
based on the selection in a DropDownList control. I want to use the
integer SelectedValue property of the DropDownList to filter the grid
based on a bitwise comparator. I could just do this in my query
select statement, but I want to cache the overall result set for
faster subquery operations.
In T-SQL the bitwise comparator is the ampersand (&), but I am
getting an invalid character exception. Does anyone here know what
the .NET compiler might accept for this type of operation?

SelectedValue is a *string*, although in your particular case those strings
might contain only digits. You have to use Int32.Parse to convert it
into a real int, where you can use the "&" operator on (at least in C#,
you didn't specify a language).

Hans Kesting
 
R

Random

I'm using VB.NET, but I don't think that should be an issue.

The problem is actually a little more complicated than what I briefly stated
before. I found a bug in .NET that won't allow me to apply more than one
type of FilterParameter to my ObjectDataSource (asp:QueryStringParameter and
asp:ControlParameter don't play nice together)... so instead I'm applying
the filter programmatically by explicity setting the FilterExpression
according to the control values.

So, on Page_Load, if the DropDownList has a SelectedValue, I write...

MyObjDataSource.FilterExpression = "(involveSM & " &
MyDropDown.SelectedValue & ") = " & MyDropDown.SelectedValue

"involveSM" is the column name in the dataset holding the integer values I
want to compare against. So, if the SelectedValue from the DropDownList is
"32", the FilterExpression should then read...

"(involveSM & 32) = 32"

I realize there are better ways to do this string operation, but I'm just
trying to get it to work first. But you can see, by doing this, that the
actual data type shouldn't be an issue, the compiler just has to evaluate
the FilterExpression.
 

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

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top