473,385 Members | 1,333 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,385 software developers and data experts.

ObjectDataSource has no values to insert error

Hello,
I'm having trouble using the insert method of an ObjectDataSource that
uses a custom DataObjectType. If I'm using a custom DataObjectType does
my insert method have to take that object, i.e.
myInsertMethod(MyCustomObjectType foobar) or can I actually specify
parameters to the insert method via the InsertParameters collection
associated with the ObjectDataSource, i.e. myInsertMethod(string name,
int age). Doing the latter I keep getting the error message
ObjectDataSource has no values to insert. Check that the 'values'
dictionary contains values,

- Harry

Jun 7 '06 #1
3 5283
On 7 Jun 2006 08:34:14 -0700, si**********@gmail.com wrote:
Hello,
I'm having trouble using the insert method of an ObjectDataSource that
uses a custom DataObjectType. If I'm using a custom DataObjectType does
my insert method have to take that object, i.e.
myInsertMethod(MyCustomObjectType foobar) or can I actually specify
parameters to the insert method via the InsertParameters collection
associated with the ObjectDataSource, i.e. myInsertMethod(string name,
int age). Doing the latter I keep getting the error message
ObjectDataSource has no values to insert. Check that the 'values'
dictionary contains values,

- Harry


Hi Harry,

I've been asked this a bunch so I thought I write a blog about it. The
short answer is:

ObjectDataSource1.InsertParameters[“roleName”].DefaultValue =
TextBoxRole.Text;
ObjectDataSource1.Insert();

The Long answer is here: http://peterkellner.net/?p=37

Good Luck.
Peter Kellner
http://peterkellner.net
Jun 7 '06 #2
Thank you Peter, that does work, however, I was under the impression
that I could do something like this in my .aspx page and achieve the
same effect as the code you posted in your reply:

<InsertParameters>
<asp:ControlParameter Name="roleName" ControlID="roleNameTextBox"
PropertyName="Text" />
</InsertParameters>

The above doesn't work and generates the error message I described in
my original post. Why am I unable to accomplish the same task using a
ControlParameter?

- Harry

PeterKellner wrote:
On 7 Jun 2006 08:34:14 -0700, si**********@gmail.com wrote:
Hello,
I'm having trouble using the insert method of an ObjectDataSource that
uses a custom DataObjectType. If I'm using a custom DataObjectType does
my insert method have to take that object, i.e.
myInsertMethod(MyCustomObjectType foobar) or can I actually specify
parameters to the insert method via the InsertParameters collection
associated with the ObjectDataSource, i.e. myInsertMethod(string name,
int age). Doing the latter I keep getting the error message
ObjectDataSource has no values to insert. Check that the 'values'
dictionary contains values,

- Harry


Hi Harry,

I've been asked this a bunch so I thought I write a blog about it. The
short answer is:

ObjectDataSource1.InsertParameters["roleName"].DefaultValue =
TextBoxRole.Text;
ObjectDataSource1.Insert();

The Long answer is here: http://peterkellner.net/?p=37

Good Luck.
Peter Kellner
http://peterkellner.net


Jun 7 '06 #3
On 7 Jun 2006 13:45:20 -0700, si**********@gmail.com wrote:
Thank you Peter, that does work, however, I was under the impression
that I could do something like this in my .aspx page and achieve the
same effect as the code you posted in your reply:

<InsertParameters>
<asp:ControlParameter Name="roleName" ControlID="roleNameTextBox"
PropertyName="Text" />
</InsertParameters>

The above doesn't work and generates the error message I described in
my original post. Why am I unable to accomplish the same task using a
ControlParameter?

- Harry


I'm thinking control parameters work on controls like gridview and
details view. not sure how you would tie it to a textbox. I'll think
on that.
Peter Kellner
http://peterkellner.net
Jun 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dotnet Gruven | last post by:
I've posted this in the adonet group, however it was suggested I might have better luck here.... ============================================================= I'm trying to use a typed dataset and...
4
by: Anne Catterick | last post by:
Hi, I have an british ASP.Net 2.0 application which is doing what (should) be very simple. But I am having issues. On my page I have a GridView as follows (some tags excluded for easy...
3
by: CWWong | last post by:
I am using DetailsView using ObjectDataSource with DataSourceTypeName assigned to the specific class. SelectMethod, UpdateMethod and DeleteMethod is working successfully, except InsertMethod. The...
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...
1
by: tparks69 | last post by:
I get the error: ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Insert' that has parameters: last_name, first_name, email, role_id, user_id, modified_by, modified_date...
4
by: J055 | last post by:
Hi I thought I was trying to do something very simple but I'm have a lot of trouble trying to do the following. <asp:FormView ID="fvGroups" runat="server" DataKeyNames="GroupID"...
0
by: Angel | last post by:
I created a Dataset Type on one project which generates a DLL. I have a web project . I created a webpage with a gridview. I attached an ObjectDatasource to the Dataset type from my other project....
1
by: =?Utf-8?B?cm9zczYxMw==?= | last post by:
I really hope this is not a case of "this silly thing will never work".....lots of time invested in troubleshooting this already. I have created a standard ASP.NET web form (.aspx) with several...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.