Change the SqlDataSource

Is it possible to change the data that is selected by the SqlDataSource. I want to check if the data coming is within a certain range. If say it 0 or null or > 100 I want to alter the data value to a default value, say 1.
simshpAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SriVaddadiCommented:
You can handle the events provided by the SqlDataSource and override the behavior
0
SriVaddadiCommented:
0
simshpAuthor Commented:
thanks ... I have looked into this event, but don't know which parameter hook on to
0
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

HainKurtSr. System AnalystCommented:
change the SelectCommand

sqlDataSource.SelectCommand="SELECT * FROM myTable where isnull(col,0)=0 or col>100"
0
HainKurtSr. System AnalystCommented:
or use FilterExpression

sqlDataSource.FilterExpression="col > {0}"
sqlDataSource.FilterParameters(0).value = 100
0
SriVaddadiCommented:
0
simshpAuthor Commented:
I need more than filter or an alternative select ... the actual value return from the db needs to be altered. So if it returns a record with id = 0 ... I want to physically change it to say 1 ... not just remove it from the selection
0
guru_samiCommented:
You can use Case like below:

select id, Price =
Case
When Price =null then 1
when Price =null > 100 then 1
else Price
End
from tblPrice

http://msdn.microsoft.com/en-us/library/ms181765.aspx
0
simshpAuthor Commented:
Looks like  the easiest solution - I assume then that one can not alter the values directly from the returned values of a sqldatasource select request
0
guru_samiCommented:
-->I assume then that one can not alter the values directly from the returned values of a sqldatasource select request

Is this for displaying purpose?

I guess you are trying to bind that datasource to some GridView or similar databound control...and you can handle one of their events to manipulate the DataItem for each row item.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
simshpAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.