Home / silverdatingagency co uk / Inserting updating and deleting data with the objectdatasource

Inserting updating and deleting data with the objectdatasource

For this example, we will be working with a made up class/table called “Person”. We’ll want to add some things to make this easier to hook up to an Object Data Source. We can go ahead and mark it above the class declaration as [Data Object(true)]. Since there is already going to be a Person class/object (that was created by the Data Context), we need to mark it as a partial class.

Partial classes are great, because it lets you split up methods / properties across multiple class files that all get compiled into 1 class.

The following table provides the properties of the Data Source View class: The Sql Data Source control represents a connection to a relational database such as SQL Server or Oracle database, or data accessible through OLEDB or Open Database Connectivity (ODBC).

Connection to data is made through two important properties Connection String and Provider Name.

The short version of it is that it’s generating a bunch of classes to match the tables in the database.

inserting updating and deleting data with the objectdatasource-49inserting updating and deleting data with the objectdatasource-22

That way you don’t have to wade through tons of other class files (depending on your project.) If you notice on the next screen, it already has all those 4 methods showing up in each of their proper tabs.In this article I will show you how you can use the Object Data Source with the Grid View control to do editing, updating, deleting and adding new records.There are several ways to perform these operations, I am using the simplest approach.It’s pretty good for testing purposes, or really small projects, but if you’re doing anything that is going to grow / is large already, then you’ll probably not want all that logic embedded in your pages.As I became more comfortable with LINQ, I decided to take on the task of switching over to the Object Data Source to bind to my List Views.User ID, First Name and Last Name are template columns and Edit and Delete columns are Command Columns which are added using smart tag option (You can view the smart tag if you right click on the Grid View control).string str Connection = "Server=abc\SQLEXPRESs; Database=Employee; Trusted_Connection=True"; Sql Connection con = new Sql Connection(str Connection); con.In the aspx code, you’ll notice the Object Data Source looks something like this: I love the tutorial but i'm having some trouble trying to get the Object Data Source to work when my Insert funtion passes in the business object.It seems like it's looking for each of the field names that are being bound in the control.Which represent a customized view of data for different data operations such as sorting, filtering, etc.The Data Source View class serves as the base class for all data source view classes, which define the capabilities of data source controls.


  1. It provides the advantage of separating the business logic and the data access logic. The ObjectDataSource can be bound to controls such as DropDownList, GridView, DetailsView and FormView. The various operations such as Select, Insert, Update and Delete can be performed using the ObjectDataSource control.

  2. Records 1 - 10 of 25. obout inc - Grid - Built in AJAX, AJAX compatible, Incredibly fast, Sorting, paging, add edit delete records, record selection, filtering, templates, scrolling, grouping, exporting, key navigation, resizable columns, cross browser, easy to customize - Before Insert / Update / Delete.

  3. Aug 15, 2015. NET web page is possible using the markup. The insert, update, select, delete commands are supported. Filtering, sorting and paging of the data are possible. ObjectDataSource User can work with the objects using the object data source. SqlDataSource User can work with Microsoft SQL Server, Oracle.

  4. Jul 26, 2009. Step 2 Create the basic 4 methods that you will likely use in a DataSource Select, Update, Delete, Insert. We'll want to create some custom methods that we can hook up our data source to in order to do those actions in the database. I'm going to write up the method declarations, without any of the logic.

  5. The ObjectDataSource Control enables user-defined classes to associate the output of their methods to data bound controls. The bindable class should have a default constructor, it should be stateless, and have methods that can be mapped to select, update, insert, and delete semantics. The object must update one item.

  6. Feb 17, 2007. MDF database that gets created in App_Data when you select the Web Site Configuration Wizard, and I'm going to edit the aspnet_Roles table using a GridView. After creating a TableAdapter by adding a new DataSet to my project and creating the necessary Select, Update, Insert, and Delete columns.

Leave a Reply

Your email address will not be published. Required fields are marked *