Mark Marina
Mark Marina

Reputation: 733

Operands of type Object used for '&'; runtime errors could occur

When I set my code behind as "STRICT" (Option Strict On), I get the following error: Operands of type Object used for '&'; runtime errors could occur.

Here's the problematic line:

dataSet.Sort = CType(ViewState("sortExp") & DESCENDING, String)

Just wanted to know what's wrong. Thanks

Upvotes: 0

Views: 2196

Answers (1)

Dennis Traub
Dennis Traub

Reputation: 51634

ViewState("sortExp") returns an object. With & you try to concatenate DESCENDING (which I assume is a string.) In strict mode this is not allowed. Try this:

dataSet.Sort = ViewState("sortExp").ToString() & DESCENDING

Upvotes: 2

Related Questions