473,503 Members | 11,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6870
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
8669
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
1853
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
8188
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
3430
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
3535
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
2014
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
6032
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
1590
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
11153
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
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7364
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...
1
7017
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
7470
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...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.