<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gvDetails" DataKeyNames="EmpId" DataSourceID="dsDetails" AutoGenerateColumns="False"
CellPadding="3" runat="server" BackColor="White" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" GridLines="Vertical">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="ChkRecords" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="EmpId" DataField="EmpId" />
<asp:BoundField HeaderText="EmpName" DataField="Emp_Name" />
<asp:BoundField HeaderText="EmpAddress" DataField="Emp_Address" />
<asp:BoundField HeaderText="EmpDept" DataField="Emp_Department" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="true" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
<asp:Button ID="shwbtn" Text="Display Checked Records" runat="server"
Font-Bold="true" onclick="CheckedRecords" /><br />
<asp:Label ID="lblmsg" runat="server" />
</div>
<asp:SqlDataSource ID="dsDetails" runat="server" ConnectionString="<%$ConnectionStrings:dbconnection %>"
SelectCommand="select * from EmployeeInformation">
</asp:SqlDataSource>
</form>
</body>
</html>
A SqlDataSource control allows us to access data stored in any relational database that supports ADO.NET. It can use the "System.Data.SqlClient" provider to access a SQL Server database. A DataSource control interacts with the DataBound controls and hides the complex data binding processes. The "SqlDataSource" represents a connection to an ADO.NET data provider that returns SQL data.
Add the ConnectionString in the Web.config file as in the following:
<connectionStrings>
<add name="dbconnection" connectionString="Data Source=; Initial Catalog=Employee;
User=abc; Password=****" providerName="SqlClient"/>
</connectionStrings>