ObjectDataSource Parameter Passing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert

    #1

    ObjectDataSource Parameter Passing

    What is the best way to pass a parameter to an ObjectDataSourc e.
    I am able to add a new parameter to the SelectParameter s, 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:
    ObjectDataSourc e1.SelectParame ters.Add("searc hCCN", "")

    I would like to accomplish the following:
    ObjectDataSourc e1.SelectParame ters.("LastName ") = "Doe"

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

    Thanks,



  • Phillip Williams

    #2
    RE: ObjectDataSourc e Parameter Passing

    The DefaultValue is the correct way to set such parameters at run-time.
    (There is no databound value to replace it)
    --
    HTH,
    Phillip Williams




    "Robert" wrote:
    [color=blue]
    > What is the best way to pass a parameter to an ObjectDataSourc e.
    > I am able to add a new parameter to the SelectParameter s, 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:
    > ObjectDataSourc e1.SelectParame ters.Add("searc hCCN", "")
    >
    > I would like to accomplish the following:
    > ObjectDataSourc e1.SelectParame ters.("LastName ") = "Doe"
    >
    > The code above does not work. There is no parameter.value , only
    > parameter.Defau ltValue. Is there a better way to set an existing parameter
    > value in an ObjectDataSourc e?
    >
    > Thanks,
    >
    >
    >[/color]

    Comment

    • Robert

      #3
      RE: ObjectDataSourc e Parameter Passing

      Thanks for the reply. I have a follow-up question:

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

      1) ObjectDataSourc e1.SelectParame ters("LastNam") .DefaultValue=" Doe"

      2) ObjectDataSourc e1.SelectParame ters.Add("LastN ame", "Doe")


      "Phillip Williams" wrote:
      [color=blue]
      > 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:
      >[color=green]
      > > What is the best way to pass a parameter to an ObjectDataSourc e.
      > > I am able to add a new parameter to the SelectParameter s, 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:
      > > ObjectDataSourc e1.SelectParame ters.Add("searc hCCN", "")
      > >
      > > I would like to accomplish the following:
      > > ObjectDataSourc e1.SelectParame ters.("LastName ") = "Doe"
      > >
      > > The code above does not work. There is no parameter.value , only
      > > parameter.Defau ltValue. Is there a better way to set an existing parameter
      > > value in an ObjectDataSourc e?
      > >
      > > Thanks,
      > >
      > >
      > >[/color][/color]

      Comment

      • Phillip Williams

        #4
        RE: ObjectDataSourc e Parameter Passing

        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.

        ObjectDataSourc e1.SelectParame ters.Add(New
        WebControls.Par ameter("OrderDa te", TypeCode.DateTi me, Now.ToString()) )

        --
        HTH,
        Phillip Williams




        "Robert" wrote:
        [color=blue]
        > Thanks for the reply. I have a follow-up question:
        >
        > Should I use the Default Value or add the parameter for best practice?
        >
        > 1) ObjectDataSourc e1.SelectParame ters("LastNam") .DefaultValue=" Doe"
        >
        > 2) ObjectDataSourc e1.SelectParame ters.Add("LastN ame", "Doe")
        >
        >
        > "Phillip Williams" wrote:
        >[color=green]
        > > 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:
        > >[color=darkred]
        > > > What is the best way to pass a parameter to an ObjectDataSourc e.
        > > > I am able to add a new parameter to the SelectParameter s, 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:
        > > > ObjectDataSourc e1.SelectParame ters.Add("searc hCCN", "")
        > > >
        > > > I would like to accomplish the following:
        > > > ObjectDataSourc e1.SelectParame ters.("LastName ") = "Doe"
        > > >
        > > > The code above does not work. There is no parameter.value , only
        > > > parameter.Defau ltValue. Is there a better way to set an existing parameter
        > > > value in an ObjectDataSourc e?
        > > >
        > > > Thanks,
        > > >
        > > >
        > > >[/color][/color][/color]

        Comment

        Working...