Using the following sub procedure, I create a confirm popup window. How do
I pass back to the calling DoItemDelete sub procedure (also shown below)
which button is clicked (OK or Cancel)? I want to make sure they really do
want to delete the record. The DoItemDelete is called via the EditTemplate
of DataList1.
Sub DoConfirm(strMsg As String)
Dim strMsgBox as String
strMsgBox = "<scr" & "ipt language=""JavaScript""
type=""text/javascript"">" & vbCrlf
strMsgBox &= " confirm('" & strMsg & "');" & vbCrlf
strMsgBox &= "</scr" & "ipt>"
Response.Write(strMsgBox)
End Sub 'DoConfirm(strMsg As String)
Sub DoItemDelete(objSource As Object, objArgs As DataListCommandEventArgs)
DoConfirm("Do you really want to DELETE this record?")
'******* if confirmed continue with following ******
'create a suitable SQL statement and execute it
Dim strSQL As String
strSQL = "DELETE product_data "
strSQL += "WHERE prod_id = '" &
DataList1.DataKeys(objArgs.Item.ItemIndex)
strSQL += "';"
ExecuteSQLStatement(strSQL)
'set EditItemIndex property of grid to -1 to switch out of Edit mode
DataList1.EditItemIndex = -1
DataList1.DataSource = CreateDataSource()
DataList1.DataBind()
End Sub 'DoItemDelete