You are on page 1of 6

ASP.

NET : DATA BIND CONTROL

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

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


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:GridView ID="GridView3" runat="server"


AutoGenerateColumns="False"
DataKeyNames="Employee_ID" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="Employee_ID"
HeaderText="Employee_ID"
ReadOnly="True" SortExpression="Employee_ID" />
<asp:BoundField DataField="First_Name" HeaderText="First_Name"
SortExpression="First_Name" />
<asp:BoundField DataField="Birth_Date" HeaderText="Birth_Date"
SortExpression="Birth_Date" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName
%>"
SelectCommand="SELECT [Employee ID] AS Employee_ID, [First Name]
AS First_Name, [Birth Date] AS Birth_Date FROM [Employee]">
</asp:SqlDataSource>

</div>
</form>
</body>
</html>
OUTPUT:

You might also like