Updating is not supported by objectdatasource

First thing you’ll need is a class to represent a row in the Grid View.For the Grid View to show the fields in the “Edit Fields…” design time dialog, you’ll need to expose the fields as Properties.The Grid View control is one of the great time savers of ASP. Sorting, paging, editing, deleting, and even AJAX (set Enable Sorting And Paging Callbacks to True) is included out of the box.The Object Data Source is the other half of the magic, connecting the Grid View to the data and managing any filter controls.I found lots of brief articles on the web about Object Data Source (ODS) but very few covered any detail, with no complete examples and many articles "cheated" by not using business objects, but by using datasets and data readers.This article is designed to take you from first-principles to a working ASP.So complex DAL objects which take a lot of time to set up are likely to need some thought or redesign before being used in an Object Data Source.For example, my existing DAL library created a whole internal dataset for every table and every relationship in the database, rather than just for the specific table required. I will use Adventure Work's Department table as our database source, and we will create a cut-down DAL class that represents this table.

After creating a Table Adapter by adding a new Data Set to my project and creating the necessary Select, Update, Insert, and Delete columns, I wire up my Grid View to an Object Data Source that uses this Table Adapter resulting in code like this: suggests that the Data Key Names property should resolve this issue, but it does not, at least when the keys are Guid values rather than ints or strings (one of the forum posters suggested the Data Key Names collection doesn’t support object typed keys). Andrew Duthie has a summary of how to fix this issue on his blog (from 2005, no less). don’t remove the keys from the WHERE part of the query!!! You will also want to remove the key parameters from the Update Command’s Parameters collection.

As business objects and other data source types can take on many different forms, data-bindable controls needed a consistent way to access and modify the underlying data.

There is a suite of Data Source-based controls (including XMLdata Source and SQLdata Source) and Sql Data Source is just one.

One of the best new features of the forthcoming ASP. However, as I found out in my experimentation what seems like a simple control has some complex behaviors to master to get it working properly.

If (like me) you have an existing data access layer you may have to make changes to be able to use Object Data Source.

Since it’s subclassed, our users won’t need to know anything about Generics to use the adapter. Data Object(true) – this tells Visual Studio to list the class in the Choose a Business Object screen of the configure datasource wizard.

You must have an account to comment. Please register or login here!