修改Maps/Customers.xml,在statements标记中加入下面代码:
 <delete id="DeleteCustomer"  parameterClass="string">
<delete id="DeleteCustomer"  parameterClass="string"> delete from Customers where CustomerID=#value#
        delete from Customers where CustomerID=#value# </delete>
        </delete>修改后的Test1.aspx

 <%
<% @ Page language="c#" Codebehind="Test1.aspx.cs" AutoEventWireup="false" Inherits="IbatisNet.Example.Test1" %>
@ Page language="c#" Codebehind="Test1.aspx.cs" AutoEventWireup="false" Inherits="IbatisNet.Example.Test1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML>
<HTML> <HEAD>
    <HEAD> <title>Test1</title>
        <title>Test1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD>
    </HEAD> <body>
    <body> <form id="Form1" method="post" runat="server">
        <form id="Form1" method="post" runat="server"> <asp:DataGrid id="dgList" runat="server" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px"
            <asp:DataGrid id="dgList" runat="server" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Horizontal" AllowPaging="True" AutoGenerateColumns="False"
                BackColor="White" CellPadding="3" GridLines="Horizontal" AllowPaging="True" AutoGenerateColumns="False" DataKeyField="CustomerID">
                DataKeyField="CustomerID"> <FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
                <FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle> <SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#738A9C"></SelectedItemStyle>
                <SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#738A9C"></SelectedItemStyle> <AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
                <AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle> <ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
                <ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle> <HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></HeaderStyle>
                <HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></HeaderStyle> <Columns>
                <Columns> <asp:BoundColumn DataField="CustomerID" HeaderText="CustomerID"></asp:BoundColumn>
                    <asp:BoundColumn DataField="CustomerID" HeaderText="CustomerID"></asp:BoundColumn> <asp:BoundColumn DataField="CompanyName" HeaderText="CompanyName"></asp:BoundColumn>
                    <asp:BoundColumn DataField="CompanyName" HeaderText="CompanyName"></asp:BoundColumn> <asp:BoundColumn DataField="Address" HeaderText="Address"></asp:BoundColumn>
                    <asp:BoundColumn DataField="Address" HeaderText="Address"></asp:BoundColumn> <asp:BoundColumn DataField="City" HeaderText="City"></asp:BoundColumn>
                    <asp:BoundColumn DataField="City" HeaderText="City"></asp:BoundColumn> <asp:BoundColumn DataField="Phone" HeaderText="Phone"></asp:BoundColumn>
                    <asp:BoundColumn DataField="Phone" HeaderText="Phone"></asp:BoundColumn> <asp:BoundColumn DataField="Fax" HeaderText="Fax"></asp:BoundColumn>
                    <asp:BoundColumn DataField="Fax" HeaderText="Fax"></asp:BoundColumn> <asp:ButtonColumn Text="删除" CommandName="Delete"></asp:ButtonColumn>
                    <asp:ButtonColumn Text="删除" CommandName="Delete"></asp:ButtonColumn> </Columns>
                </Columns> <PagerStyle HorizontalAlign="Right" ForeColor="#4A3C8C" BackColor="#E7E7FF"></PagerStyle>
                <PagerStyle HorizontalAlign="Right" ForeColor="#4A3C8C" BackColor="#E7E7FF"></PagerStyle> </asp:DataGrid>
            </asp:DataGrid> </form>
        </form> </body>
    </body> </HTML>
</HTML>
修改后的Test1.aspx.cs
 //***********************************************************
//*********************************************************** //*公司:
//*公司: //*作者:YK
//*作者:YK //*模块:Test1
//*模块:Test1 //*功能:
//*功能: //*创建日期:
//*创建日期: //*修改日期:
//*修改日期: //***********************************************************
//*********************************************************** using System;
using System; using System.Collections;
using System.Collections; using System.ComponentModel;
using System.ComponentModel; using System.Data;
using System.Data; using System.Drawing;
using System.Drawing; using System.Web;
using System.Web; using System.Web.SessionState;
using System.Web.SessionState; using System.Web.UI;
using System.Web.UI; using System.Web.UI.WebControls;
using System.Web.UI.WebControls; using System.Web.UI.HtmlControls;
using System.Web.UI.HtmlControls; using IBatisNet.Common;
using IBatisNet.Common; using IBatisNet.Common.Utilities;
using IBatisNet.Common.Utilities; using IBatisNet.DataMapper;
using IBatisNet.DataMapper; using IBatisNet.DataAccess;
using IBatisNet.DataAccess; namespace IbatisNet.Example
namespace IbatisNet.Example

 {
{
 /**//// <summary>
    /**//// <summary> /// Test1 的摘要说明。
    /// Test1 的摘要说明。 /// </summary>
    /// </summary> public class Test1 : System.Web.UI.Page
    public class Test1 : System.Web.UI.Page
 
     {
{ protected System.Web.UI.WebControls.DataGrid dgList;
        protected System.Web.UI.WebControls.DataGrid dgList; 
     private void Page_Load(object sender, System.EventArgs e)
        private void Page_Load(object sender, System.EventArgs e)
 
         {
{ // 在此处放置用户代码以初始化页面
            // 在此处放置用户代码以初始化页面
 if(!Page.IsPostBack)
            if(!Page.IsPostBack)
 
             {
{ 
             this.GetData();
                this.GetData(); }
            } }
        }

 Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
        Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e)
        override protected void OnInit(EventArgs e)
 
         {
{ //
            // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
            // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 //
            // InitializeComponent();
            InitializeComponent(); base.OnInit(e);
            base.OnInit(e); }
        } 
        
 /**//// <summary>
        /**//// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。
        /// 此方法的内容。 /// </summary>
        /// </summary> private void InitializeComponent()
        private void InitializeComponent()
 
         {
{     this.dgList.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgList_PageIndexChanged);
            this.dgList.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgList_PageIndexChanged); this.dgList.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgList_DeleteCommand);
            this.dgList.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgList_DeleteCommand); this.Load += new System.EventHandler(this.Page_Load);
            this.Load += new System.EventHandler(this.Page_Load);
 }
        } #endregion
        #endregion private void GetData()
        private void GetData()
 
         {
{ this.dgList.DataSource =IbatisNet.Example.Mapper.Instance().QueryForList("GetAllCustomers",null);
            this.dgList.DataSource =IbatisNet.Example.Mapper.Instance().QueryForList("GetAllCustomers",null); this.dgList.DataBind();
            this.dgList.DataBind(); }
        }
 //翻页
        //翻页 private void dgList_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
        private void dgList_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
 
         {
{ this.dgList.CurrentPageIndex = e.NewPageIndex;
            this.dgList.CurrentPageIndex = e.NewPageIndex; this.GetData();
            this.GetData(); }
        }
 //删除
        //删除
 private void dgList_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        private void dgList_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)  {
{ string customerID = this.dgList.DataKeys[e.Item.ItemIndex].ToString();
            string customerID = this.dgList.DataKeys[e.Item.ItemIndex].ToString(); IbatisNet.Example.Mapper.Instance().Delete("DeleteCustomer",customerID);
            IbatisNet.Example.Mapper.Instance().Delete("DeleteCustomer",customerID);
 if(this.dgList.CurrentPageIndex>0&&this.dgList.Items.Count==1)
            if(this.dgList.CurrentPageIndex>0&&this.dgList.Items.Count==1)  {
{ this.dgList.CurrentPageIndex = this.dgList.CurrentPageIndex -1;
                this.dgList.CurrentPageIndex = this.dgList.CurrentPageIndex -1;  }
            } this.GetData();
            this.GetData(); }
        } }
    } }
}