Data source controls in asp.net - Part 2

The following are some of the different data source controls that are available in asp.netSqlDataSource - Use to work with SQL Server, OLE DB, ODBC, or Oracle databasesObjectDataSource - Use to work business objects, that manages dataAccessDataSource - Use to work with Microsoft AccessXmlDataSource - Use to work with XML filesLinqDataSource - Enables us to use LINQ, to retrieve and modify data from a data objectEntityDataSource - Use to work with Entity Data Model

Prior to the introduction of data source controls, developers had to write a few lines of code to retrieve and bind data with data-bound controls like DataGrid, GridView, DataList etc. With the introduction of these data source controls, we don't have to write even a single line of code, to retrieve and bind data to a data-bound control.

We will discuss about, each of these data source controls in our upcoming videos.

To bind data to a data bound control, like gridview there are 2 ways1. Without using data-source controls2. Using data-source controls

If we are not using data source controls, then we have to write code to 1. Read connection string2. Create connection object3. Create SQL Command object4. Execute the command5. Retrieve and bind the results to the data-bound control.

If we are using data source controls, we don't have to write even a single line of code. All, you have to do is, drag and drop a data-source control on the webform. Configure the data-source control to connect to a data source and retrieve data. Finally associate the data-source control, to a data-bound control using "DataSourceID" property.

Points to remember:1. "ConnectionString" property of the "SqlDataSource" control is used to determine the database it has to connect, to retrieve data2. "SelectCommand" property specifies the command that needs to be executed.3. DataSource control is associated, with the gridview control, using "DataSourceID" property of the GridView control.