I guess I'm behind the curve on this one, or I finally ran into the rare circumstances where this happens. Evidently when you're using a SqlDataSource, and you execute a select where one or more parameters is null, you get no errors and no data. Especially when you're plugging this into a larger declarative structure like a ListView.
Ran into this today when I was using the SqlDataSource and ListView to look up users based on one of three parameters, where I expected at least one of them to be null. I didn't expect the seemingly weird behavior when my ListView kept showing up empty, but the query with the same parameters worked just fine.
Props to Christopher for posting about this one, and helping me find a clue.
TL;DR - you have to set the CancelSelectOnNullParameter to false, if you want to pass null parameter values, or the query will get cancelled before it even starts.
1 comment:
Thanks for this. 3 days of bashing head against wall on numerous red herrings and questioning what was wrong in my code (nothing!)...and came across this...now works. Bump!
Post a Comment