Datasheet

Listing 1-2: (continued)
<body>
<form id=”Form1” runat=”server”>
<asp:SqlDataSource id=”categorySource” runat=”server”
ConnectionString=”server=localhost;database=AdventureWorks;uid=user;pwd=word”
SelectCommand=”SELECT * From Production.ProductCategory”>
</asp:SqlDataSource>
<asp:GridView DataSourceID=”categorySource” runat=”server” id=”gridCategories”>
</asp:GridView>
</form>
</body>
</html>
The code declares a SqlDataSource control and a GridView control. The SqlDataSource control dec-
laration also specifies the connection string and the SQL statement to be executed as attributes. The
DataSourceID attribute in the GridView is the one that links the SqlDataSource control to the
GridView control. That’s all there is to retrieving the data from the database and displaying it in a web
page. Figure 1-1 shows the output produced by the page when requested from the browser.
Figure 1-1
Security Controls
With the large amount of business being done on the web, security is vitally important for protecting not
only confidential information such as credit card numbers, but also users’ personal details and preferences.
Thus, most of the web applications require the capability to authenticate users on their web sites. Although
this was easy to do in ASP.NET 1.x, you still had to write code. With ASP.NET 2.0, things have changed for
the better. For security-related functionalities, ASP.NET 2.0 introduces a wide range of new controls:
<asp:Login>: Provides a standard login capability that allows the users to enter their credentials
<asp:LoginName>: Allows you to display the name of the logged-in user
<asp:LoginStatus>: Displays whether the user is authenticated or not
10
Part I: Introduction
05_041796 ch01.qxp 12/29/06 9:09 PM Page 10