📄 aspnet03-01.htm
字号:
<tr>
<td>SW444</td>
<td>Programming PHP</td>
<td>39.95</td>
<td>17</td></tr>
<tr>
<td>SW555</td>
<td>Visual Basic.NET Programming</td>
<td>49.99</td>
<td>13</td></tr>
<tr>
<td>SY111</td>
<td>Operating System Concepts</td>
<td>95.75</td>
<td>1</td></tr>
<tr>
<td>SY222</td>
<td>The UNIX Operating System</td>
<td>19.95</td>
<td>12</td></tr>
<tr>
<td>SY333</td>
<td>Windows Server 2003</td>
<td>29.99</td>
<td>25</td></tr>
<tr>
<td>SY444</td>
<td>Linux in a Nutshell</td>
<td>44.95</td>
<td>14</td></tr>
<tr>
<td>SY555</td>
<td>Mastering Active Directory</td>
<td>49.99</td>
<td>8</td></tr>
<tr>
<td>WB111</td>
<td>Ajax in Action</td>
<td>22.67</td>
<td>14</td></tr>
<tr>
<td>WB222</td>
<td>Professional ASP.NET 2.0</td>
<td>32.99</td>
<td>21</td></tr>
<tr>
<td>WB333</td>
<td>Cascading Style Sheets</td>
<td>39.95</td>
<td>6</td></tr>
<tr>
<td>WB444</td>
<td>DOM Scripting</td>
<td>23.09</td>
<td>8</td></tr>
<tr>
<td>WB555</td>
<td>Microsoft ASP.NET 2.0</td>
<td>29.99</td>
<td>12</td></tr></tbody></table></div><br></div>
<div class="figure"><b>Figure 3-4. </b>Page output produced from an external data
source.</div>
<p>As you can see in the following code listing, there is very little XHTML on
the page and no scripts. All server processing is incapsulated in the two server
controls coded on the page.</p><pre class="divcode"><?xml version="1.0" encoding="UTF-8"?>
<!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" xml:lang="en">
<head>
<title>Database-Generated Page Output</title>
</head>
<form Runat="Server">
<h3>Database-Generated Page Output</h3>
<asp:AccessDataSource id="BookSource" Runat="Server"
DataFile="c:\eCommerce\Databases\BooksDB.mdb"
SelectCommand="SELECT BookID, BookTitle, BookPrice, BookQty FROM Books
ORDER BY BookID"/>
<asp:GridView id="BookGrid" DataSourceID="BookSource" Runat="Server"/>
</form>
</body>
</html>
</pre>
<div class="listing"><b>Listing 3-4.</b> Code for page produced from an external
data source.</div></div>
<p>Only two server controls are needed to produce page output. An <span class="code"><asp:GridView></span> control, one of the information display
controls to which external data can be bound, automatically produces a table
display of provided information. An <span class="code"><asp:AccessDateSource></span> control extracts information from
the database. It is associated with the GridView through the latter's <span class="code">DataSourceID</span> property so that retrieved information is
displayed in the format given by the GridView. No special styling is applied to
the output table; however, there is a full range of layout and styling options
that can be applied to a GridView. Although not shown in this example, various
user input controls can be added to the page so that users can make choices
about which information to extract and display as output.</p>
<p class="head2">Separating Web Content from Page Display</p>
<p>An advantage of maintaining Web page content in external data stores is that
it is more likely to be the most current and most accurate information. For
commercial Web sites especially, much of the content already resides in
corporate databases representing the storehouses of information used to operate
and manage the enterprise. Web pages are current and accurate to the extent they
can draw out and display this information in a timely manner. It makes little
sense to hard code this information on a Web page as text and XHTML when the
information itself can change a minute or two later. Better that Web page
information be live, extracted from these data sources the exact second it is
requested.</p>
<p>A second advantage of keeping page content separate from its on-page display
is that the Web page itself seldom, if ever, requires editing. As long as the
arrangment and presentation of information is satisfactory, page coding is never
changed while page content changes regularly, as often as the information in the
data stores change. The page always presents the most current information with
no involvement of the page developer and no need for a technical or clerical
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -