ASP.NET Tutorial/Data Binding/DataSource control — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 11:58, 26 мая 2010
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>