日期:2012-09-26 浏览次数:21007 次
现在数据库中建立test表,字段分别为ID、Code、Name;
数据库的链接这里就不具体写了,数据库的链接和操作请求我写在了AreaInfo.cs中,代码中会用到,这里声明一下
<%@ Page language="c#" Codebehind="Update.aspx.cs" AutoEventWireup="false" Inherits="Client.Page.AreaInfo.Update" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>test</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout" bgcolor="ivory">
<font face="arial" size="3"></font><FONT style="BACKGROUND-COLOR: #ffffff" face="Arial">
</FONT>
<br>
<form runat="server" ID="Form1">
<TABLE id="Table1" cellSpacing="0" bgcolor="#6699cc" cellPadding="1" width="300" border="1">
<TR>
<TD><b>test</b>
</TD>
</TR>
<TD>
<asp:DataGrid id="DG1" runat="server" BorderColor="green" Width="640" PageSize="5" AllowPaging="true"
OnPageIndexChanged="Page_Grid" BorderWidth="1" CellPadding="3" AutoGenerateColumns="false"
ShowHeader="true" Visible="true" OnEditCommand="People_Edit" OnCancelCommand="People_Cancel"
OnUpdateCommand="People_Update" OnDeleteCommand="People_Delete">
<HeaderStyle BorderColor="White" BackColor="black" ForeColor="White" Font-Bold="True" Font-Name="Arial"
Font-Size="9" HorizontalAlign="Center" />
<ItemStyle BorderColor="" BackColor="#FFFFF0" ForeColor="Black" Font-Name="Arial" Font-Size="8"
Font-Bold="False" HorizontalAlign="Center" />
<EditItemStyle BorderColor="" BackColor="#FFFFF0" ForeColor="Black" Font-Name="Arial" Font-Size="7"
Font-Bold="False" HorizontalAlign="Center" />
<PagerStyle Mode="NumericPages" Font-Size="8" />
<Columns>
<asp:BoundColumn HeaderText="ID" ReadOnly="true" DataField="ID" />
<asp:TemplateColumn>
<HeaderTemplate>
<b>代码</b>
</HeaderTemplate>
<ItemTemplate>
<asp:Label Text='<%# DataBinder.Eval(Container.DataItem, "Code").ToString().Trim() %>' runat="server" ID="Label1" NAME="Label1"/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="Code" Text='<%# DataBinder.Eval(Container.DataItem, "Code").ToString().Trim() %>' runat="server" Width="100%"/>
&n