ASP.NET中修改删除DataGrid行—数据库访问
点击次数:21 次 发布日期:2008-11-27 02:20:15 作者:源代码网
|
源代码网推荐 创建一个WEB页面,命名为:Add.aspx。 源代码网推荐 源代码网推荐 Add.aspx代码: 源代码网推荐 源代码网推荐 <%@ Page language="c#" Codebehind="Add.aspx.cs" AutoEventWireup="false" Inherits="TeachShow.Charpter7.AccessDataBase.Add" %> 源代码网推荐 源代码网推荐 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 源代码网推荐 源代码网推荐 <HTML> 源代码网推荐 源代码网推荐 <HEAD> 源代码网推荐 源代码网推荐 <title>Add</title> 源代码网推荐 源代码网推荐 <LINK href="../../Style.css" type="text/css" rel="stylesheet"> 源代码网推荐 源代码网推荐 <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> 源代码网推荐 源代码网推荐 <meta content="C#" name="CODE_LANGUAGE"> 源代码网推荐 源代码网推荐 <meta content="JavaScript" name="vs_defaultClientScript"> 源代码网推荐 源代码网推荐 <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> 源代码网推荐 源代码网推荐 </HEAD> 源代码网推荐 源代码网推荐 <body MS_POSITIONING="GridLayout"> 源代码网推荐 源代码网推荐 <form id="Form1" method="post" runat="server"> 源代码网推荐 源代码网推荐 <div align="center"> 源代码网推荐 源代码网推荐 <center> 源代码网推荐 源代码网推荐 <table class="smallBlack" height="318" cellSpacing="0" cellPadding="0" width="429" border="0"> 源代码网推荐 源代码网推荐 <tr> 源代码网推荐 源代码网推荐 <td class="title" vAlign="top" width="429" colSpan="2" height="31">添加一个新的发行者</td> 源代码网推荐 源代码网推荐 </tr> 源代码网推荐 源代码网推荐 <tr> 源代码网推荐 源代码网推荐 <td vAlign="top" width="79" height="23">发行者ID:</td> 源代码网推荐 源代码网推荐 <td vAlign="top" width="350" height="23"><asp:textbox id="TextBox1" runat="server" Height="18px" CssClass="smallRed"></asp:textbox><FONT face="宋体">(以99打头,共4位数字)</FONT></td> 源代码网推荐 源代码网推荐 </tr> 源代码网推荐 源代码网推荐 <tr> 源代码网推荐 源代码网推荐 <td vAlign="top" width="79" height="23"><FONT face="宋体">姓名:</FONT></td> 源代码网推荐 源代码网推荐 <td vAlign="top" width="350" height="23"><asp:textbox id="TextBox2" runat="server" Height="18px" CssClass="smallRed"></asp:textbox></td> 源代码网推荐 源代码网推荐 </tr> 源代码网推荐 源代码网推荐 <tr> 源代码网推荐 源代码网推荐 <td vAlign="top" width="79" height="23"><FONT face="宋体">城市:</FONT></td> 源代码网推荐 源代码网推荐 <td vAlign="top" width="350" height="23"><asp:textbox id="TextBox3" runat="server" Height="18px" CssClass="smallRed"></asp:textbox></td> 源代码网推荐 源代码网推荐 </tr> 源代码网推荐 源代码网推荐 <tr> 源代码网推荐 源代码网推荐 <td vAlign="top" width="79" height="23"><FONT face="宋体">省份:</FONT></td> 源代码网推荐 源代码网推荐 <td vAlign="top" width="350" height="23"><asp:textbox id="TextBox4" runat="server" Height="18px" CssClass="smallRed"></asp:textbox><FONT face="宋体">(2个字符)</FONT></td> 源代码网推荐 源代码网推荐 </tr> 源代码网推荐 源代码网推荐 <tr> 源代码网推荐 源代码网推荐 <td vAlign="top" width="79" height="24"><FONT face="宋体">国家:</FONT></td> 源代码网推荐 源代码网推荐 <td vAlign="top" width="350" height="24"><asp:textbox id="TextBox5" runat="server" Height="18px" CssClass="smallRed"></asp:textbox></td> 源代码网推荐 源代码网推荐 </tr> 源代码网推荐 源代码网推荐 <tr> 源代码网推荐 源代码网推荐 <td vAlign="top" align="center" width="429" colSpan="2" height="24"><asp:linkbutton id="LinkButton1" runat="server">提交到数据库</asp:linkbutton></td> 源代码网推荐 源代码网推荐 </tr> 源代码网推荐 源代码网推荐 <tr> 源代码网推荐 源代码网推荐 <td width="429" height="147" valign="top" colspan="2"> 源代码网推荐 源代码网推荐 <asp:DataGrid id="DataGrid1" runat="server" Height="120px" CssClass="general" Width="428px"> 源代码网推荐 源代码网推荐 <ItemStyle Width="50px"></ItemStyle> 源代码网推荐 源代码网推荐 <Columns> 源代码网推荐 源代码网推荐 <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="更新" CancelText="取消" EditText="编辑"> 源代码网推荐 源代码网推荐 <HeaderStyle Width="60px"></HeaderStyle> 源代码网推荐 源代码网推荐 </asp:EditCommandColumn> 源代码网推荐 源代码网推荐 <asp:ButtonColumn Text="删除" CommandName="Delete"></asp:ButtonColumn> 源代码网推荐 源代码网推荐 </Columns> 源代码网推荐 源代码网推荐 </asp:DataGrid></td> 源代码网推荐 源代码网推荐 </tr> 源代码网推荐 源代码网推荐 </table> 源代码网推荐 源代码网推荐 </center> 源代码网推荐 源代码网推荐 </div> 源代码网推荐 源代码网推荐 </form> 源代码网推荐 源代码网推荐 </body> 源代码网推荐 源代码网推荐 </HTML> 源代码网推荐 源代码网推荐 Add.asp.cs代码: 源代码网推荐 源代码网推荐 using System; 源代码网推荐 源代码网推荐 using System.Collections; 源代码网推荐 源代码网推荐 using System.ComponentModel; 源代码网推荐 源代码网推荐 using System.Data; 源代码网推荐 源代码网推荐 using System.Data.SqlClient; 源代码网推荐 源代码网推荐 using System.Drawing; 源代码网推荐 源代码网推荐 using System.Web; 源代码网推荐 源代码网推荐 using System.Web.SessionState; 源代码网推荐 源代码网推荐 using System.Web.UI; 源代码网推荐 源代码网推荐 using System.Web.UI.WebControls; 源代码网推荐 源代码网推荐 using System.Web.UI.HtmlControls; 源代码网推荐 源代码网推荐 namespace TeachShow.Charpter7.AccessDataBase 源代码网推荐 源代码网推荐 { 源代码网推荐 源代码网推荐 /// <summary> 源代码网推荐 源代码网推荐 /// Add 的摘要说明。 源代码网推荐 源代码网推荐 /// </summary> 源代码网推荐 源代码网推荐 public class Add : System.Web.UI.Page 源代码网推荐 源代码网推荐 { 源代码网推荐 源代码网推荐 protected System.Web.UI.WebControls.TextBox TextBox1; 源代码网推荐 源代码网推荐 protected System.Web.UI.WebControls.TextBox TextBox2; 源代码网推荐 源代码网推荐 protected System.Web.UI.WebControls.TextBox TextBox3; 源代码网推荐 源代码网推荐 protected System.Web.UI.WebControls.TextBox TextBox4; 源代码网推荐 源代码网推荐 protected System.Web.UI.WebControls.LinkButton LinkButton1; 源代码网推荐 源代码网推荐 protected System.Web.UI.WebControls.DataGrid DataGrid1; 源代码网推荐 源代码网推荐 protected System.Web.UI.WebControls.TextBox TextBox5; 源代码网推荐 源代码网推荐 private void Page_Load(object sender, System.EventArgs e) 源代码网推荐 源代码网推荐 { 源代码网推荐 源代码网推荐 // 在此处放置用户代码以初始化页面 源代码网推荐 源代码网推荐 if(!this.IsPostBack) 源代码网推荐 源代码网推荐 { 源代码网推荐 源代码网推荐 this.BindGrid(); 源代码网推荐 源代码网推荐 } 源代码网推荐 源代码网推荐 } 源代码网推荐 源代码网推荐 #region Web 窗体设计器生成的代码 源代码网推荐 源代码网推荐 override protected void OnInit(EventArgs e) 源代码网推荐 源代码网推荐 { 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网供稿. |
