此文章包含Page_Load,Search,Delete,Edit,翻页事件, 只用了.nettiers 的Data,Entites,Service层,没有用Web层
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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" >
<head id="Head1" runat="server">
<title>Home Page</title>
<link href="App_Themes/Default/Default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<strong>Look For CompanyName:</strong><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search" /><br />
<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="3" ForeColor="#333333" GridLines="None" DataKeyNames="CustomerId" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowDataBound="GridView1_RowDataBound" OnPageIndexChanging="GridView1_PageIndexChanging" Height="100%" Width="100%">
<Columns>
<asp:BoundField DataField="CustomerId" HeaderText="Customer Id" SortExpression="CustomerID" ReadOnly=True />
<asp:BoundField DataField="CompanyName" HeaderText="Company Name" SortExpression="CompanyName" />
<asp:BoundField DataField="ContactName" HeaderText="Contact Name" SortExpression="ContactName" />
<asp:BoundField DataField="ContactTitle" HeaderText="Contact Title" />
<asp:BoundField DataField="Address" HeaderText="Address" Visible="False" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Region" HeaderText="Region" SortExpression="Region" />
<asp:BoundField DataField="PostalCode" HeaderText="Postal Code" SortExpression="PostalCode" />
<asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
<asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" Visible="False" />
<asp:BoundField DataField="Fax" HeaderText="Fax" />
<asp:BoundField DataField="CustomerPs" HeaderText="CustomerPs" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<PagerSettings Mode="NumericFirstLast" />
</asp:GridView>
<br />
<asp:Button ID="btnCustomers" runat="server" OnClientClick="javascript:location.href='EditDefault.aspx?CustomerId='; return false;" Text="Add New" />
<asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label></div>
</form>
</body>
</html>