<%@ Page Language="VB" AutoEventWireup="false"%>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Books]"></asp:SqlDataSource>
</div>
<asp:GridView ID="GridView1"
runat="server"
AutoGenerateColumns="False"
BackColor="#FFE0C0"
BorderColor="Purple"
BorderStyle="Solid"
BorderWidth="5px"
DataKeyNames="BookID"
DataSourceID="SqlDataSource1"
EmptyDataText="There are no books!"
Font-Names="Verdana"
Font-Size="X-Small"
GridLines="None">
<Columns>
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" >
<ItemStyle Font-Italic="True" />
</asp:BoundField>
<asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
<asp:BoundField DataField="PageCount" HeaderText="Pages" SortExpression="PageCount" />
<asp:BoundField DataField="YearPublished" HeaderText="Published" SortExpression="YearPublished" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" DataFormatString="{0:c}" HtmlEncode="False" />
<asp:BoundField DataField="LastReadOn" HeaderText="Last Read" SortExpression="LastReadOn" DataFormatString="{0:d}" HtmlEncode="False" />
</Columns>
<HeaderStyle BackColor="Green" Font-Size="Medium" Font-Underline="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#E0E0E0" />
</asp:GridView>
</form>
</body>
</html>
File: Web.config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyFirstDatabase.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
|