Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Dropdownlist in EditItemTemplate with an ObjectDataSource

Dropdownlist in EditItemTemplate with an ObjectDataSource

Scheduled Pinned Locked Moved ASP.NET
visual-studiocomquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adam Wimsatt
    wrote on last edited by
    #1

    When I perform the instructions found here: http://msdn2.microsoft.com/en-us/library/ms178294(VS.80).aspx[^] It works perfectly, but when I switch to using an ObjectDataSource instead of a SQLDataSource it throws an exception: "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." Is there anything I can do to the ObjectDataSource to make it work as described in the instructions in the link above?


    K 1 Reply Last reply
    0
    • A Adam Wimsatt

      When I perform the instructions found here: http://msdn2.microsoft.com/en-us/library/ms178294(VS.80).aspx[^] It works perfectly, but when I switch to using an ObjectDataSource instead of a SQLDataSource it throws an exception: "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." Is there anything I can do to the ObjectDataSource to make it work as described in the instructions in the link above?


      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      The error you are getting seems to indicate that one of your properties is coming across as null. I would guess that what ever you are using to populate your collection of your objects isn't properly defaulting some of the values. It seems like it is the values of the primary or foreign keys. Hope that helps. Ben

      A 1 Reply Last reply
      0
      • K kubben

        The error you are getting seems to indicate that one of your properties is coming across as null. I would guess that what ever you are using to populate your collection of your objects isn't properly defaulting some of the values. It seems like it is the values of the primary or foreign keys. Hope that helps. Ben

        A Offline
        A Offline
        Adam Wimsatt
        wrote on last edited by
        #3

        I appreciate your quick response. My problem is that it works when I use a SQLDataSource but doesn't work when using an ObjectDataSource. My question is why does it not work with the objectDS when it does work with the SQLDS? The reason I want to use the ObjectDataSource is so that I can add more functionality to the Object. If I could just get it to work as a dropdown in the Gridview Edit, I would be good to go.


        K 1 Reply Last reply
        0
        • A Adam Wimsatt

          I appreciate your quick response. My problem is that it works when I use a SQLDataSource but doesn't work when using an ObjectDataSource. My question is why does it not work with the objectDS when it does work with the SQLDS? The reason I want to use the ObjectDataSource is so that I can add more functionality to the Object. If I could just get it to work as a dropdown in the Gridview Edit, I would be good to go.


          K Offline
          K Offline
          kubben
          wrote on last edited by
          #4

          The difference is the dataset that the sqldatasource returns is very different then the collection of Ienumerable of your object. I have written an article on the gridview that uses the object datasource. So it is not quite the same as what you are trying to do with the downdownlist. If you are just trying to set the source ofthe dropdown in your gridview that shouldn't be too hard. If you are trying to populate the dropdown I can see how that would be a little harder. Ben

          A 1 Reply Last reply
          0
          • K kubben

            The difference is the dataset that the sqldatasource returns is very different then the collection of Ienumerable of your object. I have written an article on the gridview that uses the object datasource. So it is not quite the same as what you are trying to do with the downdownlist. If you are just trying to set the source ofthe dropdown in your gridview that shouldn't be too hard. If you are trying to populate the dropdown I can see how that would be a little harder. Ben

            A Offline
            A Offline
            Adam Wimsatt
            wrote on last edited by
            #5

            Thank-you for your responses. I started thinking through it and realized that I was headed in the wrong direction. I switched to using the SQLDataSource and it's working great. It was a case of trying to make it more complicated than it needed to be. Thanks for you help.


            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups