Three steps need to be applied
1.
Private Sub polGrid_ItemDataBound(ByVal sender As
Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)
Handles polgrid.ItemDataBound
Dim sPolicyID As String
If e.Item.ItemType = ListItemType.Item Or
e.Item.ItemType = ListItemType.AlternatingItem Then
sPolicyID = e.Item.Cells(2).Text.Trim
Dim strMessage As String
strMessage = "Please confirm if you want
to delete this PolicyID : " & sPolicyID & "\n .Click
Ok to delete the selected policy!"
e.Item.Cells(1).Attributes.Add("onclick",
"return confirm('" & strMessage & "');")
End If
2.
Public Sub polGrid_Delete(ByVal Source As Object,
ByVal E As DataGridCommandEventArgs) Handles
polgrid.DeleteCommand
Errmsg.Text = ""
Dim sPolicyID As Integer
Dim sCommandName As String =
UCase(E.CommandName.ToString.Trim)
If E.CommandSource.CommandName = "Delete" Then
Try
sPolicyID = E.Item.Cells(2).Text.Trim
dt = pol.PolicyDelete(sPolicyID)
Catch ex As Exception
Message = ex.Message
Finally
Errmsg.Text = ""
End Try
msgDelete.Text = "Record deleted
successfully"
End If
LoadGrid
End Sub
3
--- Dean Fiala <[EMAIL PROTECTED]> wrote:
> You need to get it to work with javascript, because
> you need to get
> the confirmation to happen on the client side. The
> delete code on the
> server only gets called if the user says yes.
>
> Check out, which uses a template column, but shows
> in excruiating
> detail what needs to happen...
>
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=228
>
> Or, a much simpler approach, that arrives at the
> same destintation.
> Your server code adds the javascript at runtime when
> you bind the
> grid...
>
>
http://www.aspit.net/code/net/confirm_datagrid_delete.asp
>
> There are also a bunch of examples in tha archives
> of this group.
>
> On 8/22/05, les_claypoo1 <[EMAIL PROTECTED]>
> wrote:
> > I have a datagrid set up with an asp:ButtonColumn
> that is set up to
> > delete the record. Right now I have the
> 'OnDeleteCommand' set to an
> > asp.net(vb) sub. Which then deletes the record.
> I want to display a
> > simple confirmation box with yes or no. Any help?
> > -all the examples I find don't fit my situation
> plus I can seem to get
> > it to work with javascript since it is serverside
> stuff.
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
>
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/