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.
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.