473,394 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
3 6861
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
3
by: mthomason | last post by:
I keep getting this error when trying to update records using an ObjectDataSource. I have seen others post similar errors...but I haven't found any solutions. ObjectDataSource...
13
by: anonymike | last post by:
Hello, I started working with the ObjectDataSource today. I have the select, and have been working on getting the update method to work. Here is the asp code for my Data source: ...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
3
by: Jeronimo Bertran | last post by:
I have a FormView that shows details of a specific record on a table. The SelecMethod returns a DataSet that includes all the fields from my Event table and other read-only fields from linked...
0
by: Diane Truyens | last post by:
I have an objectdatasource on a dataset. From a webform (textbox) I want to pass a parameter to this dataset which can be null. If so I want all the rows of that dataset to be retrieved in a...
4
by: tim.cavins | last post by:
I have a GridView populated by an ObjectDataSource. I am having issues passing the parameters to the objectdatasource. I have verified that the method is being called but none of the parameters...
0
by: fig000 | last post by:
Hi, I'm using an objectdatasource. The insert procedure called by the objectdatasource is in a separate library file outside of the aspx and the codebehind that is using the objectdatasource in...
3
by: btreddy | last post by:
Hii all, I've a problem regarding passing select parameters to objectdatasource from code behind. i would like to pass the select parameters to a objectdatasource ..not in the selecting or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.