Dropdownlist in EditItemTemplate with an ObjectDataSource
-
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?
-
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?
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
-
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
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.
-
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.
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
-
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
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.