<%@ Page Language="vb" AutoEventWireup="false" Codebehind="showorder.aspx.vb" Inherits="orderform.showorder"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>showorder</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<link href="style_css.css" rel="stylesheet" type="text/css">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P><FONT face="宋体">&nbsp;</P>
<P align="center">
<asp:DataGrid id="DataGrid1" runat="server" Width="532px" AutoGenerateColumns="False" DataKeyField="id" OnItemCommand="del_data">
<HeaderStyle HorizontalAlign="Center" BackColor="#ff6633" Font-Bold="True"></HeaderStyle>
<ItemStyle BackColor="Azure" HorizontalAlign="Center" Width="600" Height=24></ItemStyle>
<SelectedItemStyle BackColor=#003366></SelectedItemStyle>
<Columns>
<asp:BoundColumn DataField="id" HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="name" HeaderText="名 称"></asp:BoundColumn>
<asp:BoundColumn DataField="email" HeaderText="Email"></asp:BoundColumn>
<asp:BoundColumn DataField="tel" HeaderText="电 话"></asp:BoundColumn>
<asp:BoundColumn DataField="content" HeaderText="订单内容"></asp:BoundColumn>
                        <asp:ButtonColumn ButtonType=PushButton HeaderText="删除" Text="删除" CommandName="del"></asp:ButtonColumn> 
</Columns>
</asp:DataGrid></P>
</FONT>
</form>
</body>
</HTML>
代码:
Imports System.Data
Imports System.Data.OleDbPublic Class showorder
    Inherits System.Web.UI.Page#Region " Web 窗体设计器生成的代码 "    '该调用是 Web 窗体设计器所必需的。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()    End Sub
    Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid    '注意: 以下占位符声明是 Web 窗体设计器所必需的。
    '不要删除或移动它。
    Private designerPlaceholderDeclaration As System.Object    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
        '不要使用代码编辑器修改它。
        InitializeComponent()
    End Sub#End Region
    Dim conn1 As New System.data.oledb.OleDbConnection
    Dim comm1 As New System.data.oledb.OleDbCommand
    Dim ad1 As New System.data.oledb.OleDbDataAdapter
    Dim ds1 As New System.Data.DataSet    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        show_data()
        DataGrid1.DataSource = ds1.Tables("orderform")
        DataGrid1.DataBind()
    End Sub    Private Sub del_data(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
        Select Case e.CommandName
            Case "del"
                DataGrid1.SelectedIndex = e.Item.ItemIndex
        End Select
        Dim id As Integer = DataGrid1.DataKeys("e.Item.ItemIndex")
        conn1.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\ASP.NET\orderform\data\data.mdb"
        conn1.Open()
        comm1.Connection = conn1
        comm1.CommandText = "delete * from orderform where id=" & id
        comm1.ExecuteNonQuery()
        comm1.CommandText = "select id,name,email,tel,content from orderform"
        ad1.SelectCommand = comm1
        ad1.Fill(ds1, "orderform")
        DataGrid1.DataSource = ds1.Tables("orderform")
        DataGrid1.DataBind()    End Sub    Function show_data()
        If Not Page.IsPostBack Then
            conn1.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\ASP.NET\orderform\data\data.mdb"
            conn1.Open()
            comm1.Connection = conn1
            comm1.CommandText = "select id,name,email,tel,content from orderform"
            ad1.SelectCommand = comm1
            ad1.Fill(ds1, "orderform")
        End If
    End Function
End Class