Setting ObjectDataSource Parameter Programmatically

  • Thread starter Thread starter JJ
  • Start date Start date
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
 
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
 
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
 
Back
Top