Home All Groups Group Topic Archive Search About

ObjectDataSource Parameter Passing

Author
14 Apr 2006 3:59 PM
Robert
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,

Author
14 Apr 2006 4:04 PM
Phillip Williams
The DefaultValue is the correct way to set such parameters at run-time. 
(There is no databound value to replace it)
Show quoteHide quote
"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,
>
>
>
Are all your drivers up to date? click for free checkup

Author
14 Apr 2006 5:15 PM
Robert
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").DefaultValue="Doe"

2) ObjectDataSource1.SelectParameters.Add("LastName", "Doe")


Show quoteHide quote
"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,
> >
> >
> >
Author
14 Apr 2006 6:01 PM
Phillip Williams
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()))

Show quoteHide quote
"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").DefaultValue="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,
> > >
> > >
> > >



Post Thread options