1. ASP.NET Introduction 2. Comp of .Net Framework 3.5 3. Sys.Req for VS 2008 4. ASP.NET Envrmnt Setup 5. VS2010 Ultimate Sys.Req 6. Installing VS 2010 7. VS 2012 Sys.Req 8. Installing VS Exp 2012 9. Start the VS 2008 10. Application Life Cycle 11. Page Life Cycle 12. Page Life Cycle Events 13. ASP.NET Example 14. Event Handling 15. Default Events 16. Server Side 17. Request Object 18. Response Object 19. Server Controls 20. Server Controls Properties 21. Server Controls Methods 22. HTML Server Controls 23. Client Side 24. ASP.NET Basic Controls 25. TextBox Control 26. CheckBox Controls 27. RadioButton Controls 28. ListBox Control 29. HyperLink Control 30. Image Control 31. BulletedList Control 32. ASP.NET Directives 33. Implements Directive 34. Master Type Directive 35. Page Directive 36. PreviousPage Type 37. Managing State 38. Control State 39. Cookies 40. Query Strings 41. Server-Side State 42. Session State 43. Validation Controls 44. Required FieldValidator 45. Range Validator 46. Compare Validator 47. RegularExpressionValidator 48. Custom Validator 49. Validation Summary 50. Data Source Control 51. AdRotator Control 52. Calendar Control 53. Calendar Control Example 54. Panel Control 55. Panel Control Example 56. Multi Views Control 57. MultiView & View controls 58. MultiView Control Example 59. FileUpload Control 60. FileUpload Control Eg 61. AJAX Control 62. UpdatePanel control 63. UpdateProgress Control 64. Custom Controls 65. Custom Control Eg 66. Personalization 67. Create Simple Profile 68. ADO.NET 69. ADO.NET Objects 70. DataTable 71. DataRow 72. DataColumn 73. Object Example 74. Error Handling 75. Tracing Errors 76. Debugger 77. Security 78. Authentication 79. Authorization 80. LINQ 81. LINQ Query Operators 82. LINQ Example 83. Caching 84. Data Caching 85. Output Caching 86. Object Caching 87. Web Services 88. Create Web Services Eg 89. Web & Machine.config 90. Settings Schema 91. ASP.NET Deployment 92. XCopy Deployment 93. Web Setup Project 94. ASP Interview Part 1 95. ASP Interview Part 2 96. ASP Interview Part 3 97. ASP Interview Part 4 98. ASP Interview Part 5 99. ASP Interview Part 6
Pr.Pg Next Pg

ASP.NET Data Source Control tutorials


  • Data Source Control is used to retrieve data from their respective types of data sources and can be bound to various data-bound controls.

  • Data source controls simplify the amount of custom code that needs to be written to retrieve and bind data, and even to sort, page through, or edit data.

  • There are several new data source controls in ASP.NET, such as the SqlDataSource, ObjectDataSource, XmlDataSource, AccessDataSource, and SiteMapDataSource.

    1. SqlDataSource : Can be used with any compatible database provider, such as SQL Server, Oracle,or MySQL. Some providers must be downloaded from the vendor websites.. The control also supports sorting, filtering, and paging when data is returned as a DataSet object.

    2. XmlDataSource : Lets you associate an XML document to a data control.

    3. SiteMapDataSource : Wraps the access to SiteMap, a feature introduced in ASP.NET 2.0 to represent a site structure.

    4. AccessDataSource : Enables you to work with a Microsoft Access database. Supports sorting, filtering, and paging when data is returned as a DataSet object.

    5. ObjectDataSource : Used with custom entities and collections, against a specific business logic.

    6. LinqDataSource : Automatically uses LINQ to SQL DataContext or any LINQ-enabled provider.

    7. EntityDataSource : Simplifies the use of Entity Framework’s object context.


Example: Using SqlDataSource Control:

  • From the Below example we have taken a gridview control for access the data from the Sql Server, firstly we will start visual studio 2010, add new websites and name the web form pages is DataSourcecntrlExmp.

  • We have created a table (Employees) in the Sql Srver. Now we have to display the record of Employees table in our web pages. There are following steps:

  • Step 1: Drag and Drop GridView Control in the DataSourcecntrlExmp.aspx page from the ToolBox: gridview


  • Step 2: Now Click on the Configure Data Source Link.and select the New data source. Which is shown in the below image: choose data source


  • Step 3: Now Select the Database from the Data Source Configuration Wizard and click the Ok button.


data source configuration


  • Step 4: Now Click on New Connection button type the Server Name and Select the database which you have to connect.


add connection

  • Step 5: After Select tha Database (DemoEmployee) Test Connection o.if the Test Connection Succefull then Click the Ok Button. The Next step shows the Save the Connection String.then click on the Next button.


configure data source

  • Step 6: After the connection is set up, you may save it for further use. At the next step, you are asked to configure the select statement then select the table (Employees) :


configure datasource


  • Step 7: After this the formatted GridView control displays the column headings. gridview


  • Step 8: Now before running the page. Bind the gridview the code file is belows.

DataSourcecntrlExmp.aspx.cs Code: 


Following example shows the use of ASP.NET SqlDataSource Control:

Sam Sir


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;


public partial class DataSourcecntrlExmp : System.Web.UI.Page


protected void Page_Load(object sender, EventArgs e)








DataSourcecntrlExmp.aspx Code:



Following example shows the use of ASP.NET SqlDataSource Control:

Sam Sir


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataSourcecntrlExmp.aspx.cs" Inherits="DataSourcecntrlExmp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">

<head runat="server">

<title> cbtSAM ASP.NET SqlDataSource Control:</title>



<form id="form1" runat="server">


Data Source Control Example:<br />

<br />

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=

"<%$ ConnectionStrings:DemoEmployeeConnectionString%>"

ProviderName= "<%$ ConnectionStrings: DemoEmployeeConnectionString.ProviderName %>" SelectCommand="SELECT [EmpID], [EmpName],

[EmpAddress], [EmpMail], [EmpPhone] FROM [Employees]">


<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"



<asp:BoundField DataField="EmpId" HeaderText="EmpId" SortExpression="EmpId" />

<asp:BoundField DataField="EmpName" HeaderText="EmpName"

SortExpression="EmpName" />

<asp:BoundField DataField="EmpAddress" HeaderText="EmpAddress"

SortExpression="EmpAddress" />

<asp:BoundField DataField="EmpMail" HeaderText="EmpMail"

SortExpression="EmpMail" />

<asp:BoundField DataField="EmpPhone" HeaderText="EmpPhone"

SortExpression="EmpPhone" />







Output data source control example


Pr.Pg border                                              Next Pg