467,877 Members | 1,309 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,877 developers. It's quick & easy.

ObjectDataSource Parameter Passing

What is the best way to pass a parameter to an ObjectDataSource.
I am able to add a new parameter to the SelectParameters, but I would like
to just assign a value to an existing parmeter at runtime.

Currently I am just adding the parameter at runtime and setting the value:
ObjectDataSource1.SelectParameters.Add("searchCCN" , "")

I would like to accomplish the following:
ObjectDataSource1.SelectParameters.("LastName") = "Doe"

The code above does not work. There is no parameter.value, only
parameter.DefaultValue. Is there a better way to set an existing parameter
value in an ObjectDataSource?

Thanks,

Apr 14 '06 #1
  • viewed: 6524
Share:
3 Replies
The DefaultValue is the correct way to set such parameters at run-time.
(There is no databound value to replace it)
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Robert" wrote:
What is the best way to pass a parameter to an ObjectDataSource.
I am able to add a new parameter to the SelectParameters, but I would like
to just assign a value to an existing parmeter at runtime.

Currently I am just adding the parameter at runtime and setting the value:
ObjectDataSource1.SelectParameters.Add("searchCCN" , "")

I would like to accomplish the following:
ObjectDataSource1.SelectParameters.("LastName") = "Doe"

The code above does not work. There is no parameter.value, only
parameter.DefaultValue. Is there a better way to set an existing parameter
value in an ObjectDataSource?

Thanks,

Apr 14 '06 #2
Thanks for the reply. I have a follow-up question:

Should I use the Default Value or add the parameter for best practice?

1) ObjectDataSource1.SelectParameters("LastNam").Defa ultValue="Doe"

2) ObjectDataSource1.SelectParameters.Add("LastName", "Doe")
"Phillip Williams" wrote:
The DefaultValue is the correct way to set such parameters at run-time.
(There is no databound value to replace it)
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Robert" wrote:
What is the best way to pass a parameter to an ObjectDataSource.
I am able to add a new parameter to the SelectParameters, but I would like
to just assign a value to an existing parmeter at runtime.

Currently I am just adding the parameter at runtime and setting the value:
ObjectDataSource1.SelectParameters.Add("searchCCN" , "")

I would like to accomplish the following:
ObjectDataSource1.SelectParameters.("LastName") = "Doe"

The code above does not work. There is no parameter.value, only
parameter.DefaultValue. Is there a better way to set an existing parameter
value in an ObjectDataSource?

Thanks,

Apr 14 '06 #3
I prefer to specify the parameter type to ensure type-casting is done
correctly particularly when the value might be affected by the Culture
setting of the server running the application. e.g.

ObjectDataSource1.SelectParameters.Add(New
WebControls.Parameter("OrderDate", TypeCode.DateTime, Now.ToString()))

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Robert" wrote:
Thanks for the reply. I have a follow-up question:

Should I use the Default Value or add the parameter for best practice?

1) ObjectDataSource1.SelectParameters("LastNam").Defa ultValue="Doe"

2) ObjectDataSource1.SelectParameters.Add("LastName", "Doe")
"Phillip Williams" wrote:
The DefaultValue is the correct way to set such parameters at run-time.
(There is no databound value to replace it)
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Robert" wrote:
What is the best way to pass a parameter to an ObjectDataSource.
I am able to add a new parameter to the SelectParameters, but I would like
to just assign a value to an existing parmeter at runtime.

Currently I am just adding the parameter at runtime and setting the value:
ObjectDataSource1.SelectParameters.Add("searchCCN" , "")

I would like to accomplish the following:
ObjectDataSource1.SelectParameters.("LastName") = "Doe"

The code above does not work. There is no parameter.value, only
parameter.DefaultValue. Is there a better way to set an existing parameter
value in an ObjectDataSource?

Thanks,

Apr 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by mthomason | last post: by
3 posts views Thread by Jeronimo Bertran | last post: by
reply views Thread by Diane Truyens | last post: by
4 posts views Thread by tim.cavins | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.