Материал из .Net Framework эксперт
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
You bind a DataBound control to a DataSource control.
A DataSource control is used to represent a particular type of data.
The ASP.NET 3.5 Framework includes the following six DataSource controls:
SqlDataSource: SQL relational database, including Microsoft SQL Server, Oracle, or DB2.
LinqDataSource: Represents a LINQ to SQL query.
AccessDataSource: Represents data retrieved from a Microsoft Access database.
ObjectDataSource: Represents data retrieved from a business object.
XmlDataSource: Represents data retrieved from an XML document.
SiteMapDataSource: Represents data retrieved from a Site Map Provider.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Bound GridView</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView
id="GridView1"
DataSourceId="srcProducts"
Runat="server" />
<asp:SqlDataSource
id="srcProducts"
ConnectionString="Data Source=.\SQLExpress;
AttachDbFilename=|DataDirectory|MyDatabase.mdf;
Integrated Security=True;User Instance=True"
SelectCommand="SELECT * FROM Products"
Runat="server" />
</div>
</form>
</body>
</html>