ObjectDataSource has no values to insert error

Discussion in 'ASP .Net' started by siamesedream@gmail.com, Jun 7, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. PeterKellner Guest

    On 7 Jun 2006 08:34:14 -0700, 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
    PeterKellner, Jun 7, 2006
    #2
    1. Advertising

  3. Guest

    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, 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, 2006
    #3
  4. PeterKellner Guest

    On 7 Jun 2006 13:45:20 -0700, 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
    PeterKellner, Jun 7, 2006
    #4
  5. cwc2006

    Joined:
    Aug 23, 2006
    Messages:
    3
    DataObjectTypeName

    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.
    cwc2006, Sep 8, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    2
    Views:
    6,924
    Guest
    Jun 28, 2005
  2. Dennis
    Replies:
    0
    Views:
    1,142
    Dennis
    Jul 1, 2006
  3. Dot Net Daddy

    ObjectDataSource has no data

    Dot Net Daddy, Aug 4, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    2,553
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Aug 5, 2006
  4. =?Utf-8?B?RGVuaXMgU29oZXQ=?=

    Error with ObjectDataSource and DetailsView - conversion error

    =?Utf-8?B?RGVuaXMgU29oZXQ=?=, Mar 28, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    414
    =?Utf-8?B?RGVuaXMgU29oZXQ=?=
    Mar 28, 2007
  5. David Thielen

    ObjectDataSource method as another ObjectDataSource

    David Thielen, Mar 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    228
    Steven Cheng[MSFT]
    Mar 23, 2006
Loading...

Share This Page