How can I set an ObjectDataSource's Parameter programmatically?
The slight complication here is that I want to set this NOT in the
'Selecting' method of the ObjectDataSource, but elsewhere.
I was hoping I could do something like:
ObjectDataSource.SelectParameters("MyParam") = thisValue.
But clearly not. I've managed to add a parameter with a value, but I cannot
reset it (it just adds another one and adds a number to its name to make it
unique):
ObjectDataSource.SelectParameters.Add("MyParam", thisValue) - works for one
itertion, but I need to set it to a new value each time.
I guess I could remove this each time and add the parameter again, but I
would have though there was a way I could change the value?
Thanks in advance,
JJ"JJ" <abc@.xyz.com> wrote in message
news:OumCh87lHHA.4152@.TK2MSFTNGP04.phx.gbl...
> How can I set an ObjectDataSource's Parameter programmatically?
> The slight complication here is that I want to set this NOT in the
> 'Selecting' method of the ObjectDataSource, but elsewhere.
> I was hoping I could do something like:
> ObjectDataSource.SelectParameters("MyParam") = thisValue.
> But clearly not. I've managed to add a parameter with a value, but I
> cannot reset it (it just adds another one and adds a number to its name to
> make it unique):
> ObjectDataSource.SelectParameters.Add("MyParam", thisValue) - works for
> one itertion, but I need to set it to a new value each time.
> I guess I could remove this each time and add the parameter again, but I
> would have though there was a way I could change the value?
> Thanks in advance,
> JJ
>
Instead of adding each time you can check the count of parameters. If it is
zero (not set) then add the parameter. Otherwise get the current parameter
from the SelectParameters collection and reset the value of the "MyParam"
parameter.
Lloyd Sheen
Ah I see. Thanks,
JJ
"Lloyd Sheen" <a@.b.c> wrote in message
news:3658866E-3CF7-4DCE-8FDF-DBEF933EBA69@.microsoft.com...
> "JJ" <abc@.xyz.com> wrote in message
> news:OumCh87lHHA.4152@.TK2MSFTNGP04.phx.gbl...
> Instead of adding each time you can check the count of parameters. If it
> is zero (not set) then add the parameter. Otherwise get the current
> parameter from the SelectParameters collection and reset the value of the
> "MyParam" parameter.
> Lloyd Sheen
Thursday, March 29, 2012
Setting ObjectDataSource Parameter Programmatically
Labels:
asp,
complication,
net,
objectdatasource,
parameter,
programmatically,
programmaticallythe,
setting,
slight
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment