当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 添加删除、更新按钮的提示确认信息,以及DATAGRID的添加、插入、更新、删除操作。

ASP.NET
ASP.NET实现数据图表a
ASP.NET实现数据图表1
Kbuilder.cs GIVE ME K
WebForm1.aspx K LINE YISHI GIEVE ME
ASP.NET实现数据图表b
today study 2005.03.03
ActiveX 组件复习笔记.1
Direct3D学习笔记(二)我们这里可以编写一个完全意义上的Direct3D程序了。
HttpContext类包含了个别HTTP请求的所有特定HTTP信息。
实现自定义分页(如:改变传统datagrid的分页显示、通过A-Z的字母来分页等)、选择...
关于Format字符串和Xml文件的解析(粗略)
wrox asp.net 2 beta preview study section 3
整合重复代码,生成自定义的列(组件)整合重复代码,生成自定义的datagrid(组件...
递归法提升密码穷举算法性能
如何用UltraEdit编译C#源程序
添加删除、更新按钮的提示确认信息,以及DATAGRID的添加、插入、更新、删除操作。
WebBrowser应用
My Composite in C#
DBForm的设计来源以及主要构想
.net中交易处理的解决方案

ASP.NET 中的 添加删除、更新按钮的提示确认信息,以及DATAGRID的添加、插入、更新、删除操作。


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 75 ::
收藏到网摘: n/a

代码using System;using System.Collections;using System.ComponentModel;using System.Data;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 DataGridDemoCS{ /// /// MSDNDemo1 的摘要说明。 /// public class MSDNDemo1 : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid DataGrid1; protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1; protected System.Data.SqlClient.SqlCommand sqlSelectCommand1; protected System.Data.SqlClient.SqlCommand sqlInsertCommand1; protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1; protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1; protected DataGridDemoCS.dsCustomers dsCustomers1; protected System.Data.SqlClient.SqlConnection sqlConnection1; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!Page.IsPostBack) { bindData(); } } void bindData() { sqlDataAdapter1.Fill(dsCustomers1); DataGrid1.DataBind(); } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// private void InitializeComponent() { this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter(); this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlConnection1 = new System.Data.SqlClient.SqlConnection(); this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand(); this.dsCustomers1 = new DataGridDemoCS.dsCustomers(); ((System.ComponentModel.ISupportInitialize)(this.dsCustomers1)).BeginInit(); this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand); this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand); this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand); this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand); this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound); // // sqlDataAdapter1 // this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1; this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1; this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1; this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "Customers", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("CustomerID", "CustomerID"), new System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"), new System.Data.Common.DataColumnMapping("ContactName", "ContactName"), new System.Data.Common.DataColumnMapping("ContactTitle", "ContactTitle"), new System.Data.Common.DataColumnMapping("Address", "Address"), new System.Data.Common.DataColumnMapping("City", "City"), new System.Data.Common.DataColumnMapping("Region", "Region"), new System.Data.Common.DataColumnMapping("PostalCode", "PostalCode"), new System.Data.Common.DataColumnMapping("Country", "Country"), new System.Data.Common.DataColumnMapping("Phone", "Phone"), new System.Data.Common.DataColumnMapping("Fax", "Fax")})}); this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1; // // sqlDeleteCommand1 // this.sqlDeleteCommand1.CommandText = @"DELETE FROM Customers WHERE (CustomerID = @Original_CustomerID) AND (Address = @Original_Address OR @Original_Address IS NULL AND Addr