GridViewEdit.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewEditTest.aspx.cs" Inherits="GridViewEditTest" %> <!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 runat="server"> <title>無標題頁</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Panel ID="pnlEdit" runat="server" Height="50px" Width="684px" Visible="False"> 姓名:<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>地址:<asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>郵編<asp:TextBox ID="txtPostCode" runat="server"></asp:TextBox><asp:Button ID="btnOK" runat="server" Text="確定" OnClick="btnOK_Click" /> <asp:Button ID="btnCancel" runat="server" Text="取消" OnClick="btnCancel_Click" /></asp:Panel> <br /> <br /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="CLientID" GridLines="Horizontal" OnPageIndexChanging="GridView1_PageIndexChanging" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" AllowPaging="True"> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="ClientName" HeaderText="姓名" SortExpression="ClientName" /> <asp:BoundField DataField="AddressStr" HeaderText="地址" SortExpression="AddressStr" /> <asp:BoundField DataField="PostCode" HeaderText="郵編" SortExpression="PostCode" /> </Columns> <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> <AlternatingRowStyle BackColor="#F7F7F7" /> </asp:GridView> </div> </form> </body> </html>