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

ASP.NET
调用另外一个同名的重载函数漏掉括号出现的严重问题
DataGrid模板列应用:在DataGrid中用CheckBox控制TextBox的Enabled属性
使用存储过程的一个小例子
.net中xmlhttp下载文件的方法参考
简单的c#文本文件读写
我的C#学习过程 第一天 安装
在数据库中开始一个事务。
用ASP.NETt实现简单的文字水印
C/S系统中三层结构(Com/Com+)的测试成功实现
VB 二进制块读写类模块应用实例,包括一个文件拷贝和一个文件二进制比较的例子。
扫雷程序“布雷”代码(vb)
关于网络连接状态的编程
c#中ref和out参数使用时需要注意的问题
use Assembly to call a method
在VBA中调用AUTOCAD打印文件
在VS.NET的
昨天折腾了一晚上,哪位高手帮我看看!急!
Net是未来的趋势吗?
如何修改自定义Webpart 的标题(downmoon)
[收藏]ASP.Net生成静态HTML页 选择自 coofucoo 的 Blog

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 102 ::
收藏到网摘: 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