Setting ObjectDataSource Parameter Programmatically

J

JJ

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
 
L

Lloyd Sheen

JJ said:
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
 
J

JJ

Ah I see. Thanks,

JJ
Lloyd Sheen said:
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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top