Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ObjectDataSource has no values to insert error

Reply
Thread Tools

ObjectDataSource has no values to insert error

 
 
siamesedream@gmail.com
Guest
Posts: n/a
 
      06-07-2006
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

 
Reply With Quote
 
 
 
 
PeterKellner
Guest
Posts: n/a
 
      06-07-2006
On 7 Jun 2006 08:34:14 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
siamesedream@gmail.com
Guest
Posts: n/a
 
      06-07-2006
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, (E-Mail Removed) 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


 
Reply With Quote
 
PeterKellner
Guest
Posts: n/a
 
      06-07-2006
On 7 Jun 2006 13:45:20 -0700, (E-Mail Removed) 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
 
Reply With Quote
 
cwc2006 cwc2006 is offline
Junior Member
Join Date: Aug 2006
Posts: 3
 
      09-08-2006
I also had trouble inserting record, however, I found out after testing for a while and google a bit, that if your specify 'DataObjectTypeName' parameter in ObjectDataSource, InsertParameters get ignored. So I just don't specify that, and it works for me.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The method of insert doesn't work with nltk texts: AttributeError: 'ConcatenatedCorpusView' object has no attribute 'insert' Token Type Python 3 09-02-2012 02:12 PM
Error: ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'InsertState' that has parameters: UsState, UsStateAbbreviation, StateId. Cirene ASP .Net 0 09-16-2008 11:40 PM
ObjectDataSource could not find a non-generic method that has parameters ... error yet again Dennis ASP .Net 0 07-01-2006 02:25 AM
ObjectDataSource method as another ObjectDataSource David Thielen ASP .Net Web Controls 3 03-23-2006 01:50 AM
Error: ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'FillMenusByLocation' that has parameters: @locationId Dotnet Gruven ASP .Net 1 09-14-2005 11:48 AM



Advertisments