Datakeyfield = "title" autogeneratecolumns = "false" runat = "server">
asp: button>
Itemtemplate>
asp: templateColumn>
asp: boundcolumn>
asp: boundcolumn>
Columns>
ask: DataGrid>
form>
body>
Html>
Postcutive code: deleteit.aspx.vb
code:
Imports System.Webimports System.collections
Imports system
Imports system.data
Imports system.data.oledb
Imports System.Web.ui.WebControls
Public Class Deleteit
Inherits System.Web.ui.page
Protected Withevents Label1 As System.Web.ui.WebControls.label
Protected withevents mydatagrid as system.web.ui.webcontrols.datagrid
#Region "The code" of the web form designer "
'This call is required for the web form designer.
private subinitializecomponent ()
End Sub
Private sub page_init (byval sender as system.object, byval e as system.eventargs) Handles mybase.init
'Codegen: This method call is necessary for the web form designer
'Don't modify it using the code editor.
InitializeComponent ()
End Sub
#End region
SUB Page_Load (Byval E as Eventargs) Handles MyBase.Load
MyDataGrid.headerstyle.font.bold = TRUE
MyDataGrid.headerstyle.horizontalalign = horizontalalign.center
MyDataGrid.columns (0) .Headertext = "Operation"
MyDataGrid.columns (1) .Headertext = "Title"
MyDataGrid.columns (2) .Headertext = "Release Date"
IF not ispostback.
DIM STRCN AS STRING = "provider = microsoft.jet.Oledb.4.0; data source =" server.mappath ("test.mdb")
DIM STRSQL AS STRING
strsql = "SELECT TOP 15 ObjectGuid, title, createdate from Document Order By CreateDate DESC"
DIM CN AS New OLEDBConnection (STRCN)
cn.open ()
DIM CMD AS New OLEDBCommand (strsql, cn)
MyDataGrid.dataSource = cmd.executeReader (Commandbehavior.CloseConnection)
MyDataGrid.Database
cmd.dispose ()
CMD = Nothing
cn.close ()
cn.dispose ()
CN = Nothing
END IF
End Sub
Sub DataGrid_Itemcreated (Byval E AS DataGriditeMeventArgs)
Handles myDataGrid.Itemcreated
Select Case E.Item.itemTypecase ListItemType.Item, ListItemType.AlternatingItem, ListItemType.editItem
DIM MyDeletebutton as button
MyDeleteButton = E.Item.FindControl ("btndelete")
MyDeleteButton.Text = "Delete this line"
MyDeleteButton.attributes.add ("Onclick", "Return Confirm ('You really want to delete" _
E.Item.itemindex.toTOString "Row? ');")
End SELECT
End Sub
Private sub mydatagrid_itemcommand (Byval Source As Object, _
Byval e as system.Web.ui.WebControls.DataGridCommandEventArgs_
Handles myDataGrid.ItemCommand
Response.write ("You want to delete: " E.Item.cells (1) .text " font>")
E.Item.BackColor = system.drawing.color.ivory
End Sub
END CLASS