首页 >> Asp.Net >> 正文
ASP.NET中修改删除DataGrid行—数据库访问-ASP.NET
来源:Dotnet频道 作者:采集 时间:2008-3-31


  创建一个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 height="318" cellSpacing="0" cellPadding="0" width="429" border="0">
  
                       <tr>
  
                           <td 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" Css></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" Css></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" Css></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" Css></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" Css></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" Css 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)
  
      {
相关新闻
相关评论
 
评论表单加载中...
 
Asp.Net文章

 在Visual C++应

 编辑:admin

 时间:2008-3-10


   .NET Framework 中多语言支持的实现-.NET Framework
   将Eiffel系统集成到.NET Framework中-.NET Framework
   04年五种常用RAD的测验比较(1)-.NET Framework
   04年五种常用RAD的测验比较(2)-.NET Framework
   04年五种常用RAD的测验比较(3)-.NET Framework
最新文章
   .NET Framework 中多语言支持的实现-.NET Framework
   将Eiffel系统集成到.NET Framework中-.NET Framework
   04年五种常用RAD的测验比较(1)-.NET Framework
   04年五种常用RAD的测验比较(2)-.NET Framework
   04年五种常用RAD的测验比较(3)-.NET Framework
总站搜索
搜索
 
热门文章
   oracle数据库文件中的导入\导出
   用Oracle10g列值掩码技术隐藏敏感数据
   VB程序中用ADO对象动态创建数据库和表-VB.NET
   用VB6写简单程序 让电骡自动关机-VB.NET
   使用.NET2.0编写COM组件供VB调用-VB.NET
   VB.NET:键盘控制焦点移动-VB.NET
   用VB.NET绘制GDI图形-VB.NET
   vb.net中应用 ArrayList 实例-VB.NET
 
推荐文章
ASP.NET中的状态管理-ASP.NET
VC、IE、ASP环境下打印、预备的完美解决方案
oracle数据库文件中的导入\导出
VB.NET中快速访问注册表技巧-VB.NET
在vb中实现超连接的方法!和直接发邮件-VB.NET
用VB做realplayer播放列表-VB.NET
在VB.NET中如何实现和利用SortedLists-VB.NET
利用VB.NET Stopwatch对象记录时间-VB.NET
成都古羌科技有限公司版权所有: Copyright@2007-2010 ,ALL Rights Reserved 蜀ICP备07017240号