Adding Confirmation Message on DATAGRID Item Delete

R

rajeshgujar

Here is What needs to be Done

In Your DataGrid do this

1 ] Private Sub DGReference_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DGReference.ItemDataBound

e.Item.Cells(5).Attributes.Add("onclick", "return
confirmDelete (this.form);") // If its the 5 th Column in the
Datagrid

End Sub


2 ] Private Sub DGReference_EditCommand(ByVal source As Object, ByVal
e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DGReference.EditCommand, DGReference.DeleteCommand
Select Case (CType(e.CommandSource, LinkButton)).CommandName
Case "Delete"
/// Give Your Delete Database Logic Here
End Select
End Sub


3 ] In the HTML Code in the Head Section

<script language="javascript">
function confirmDelete (frm)
{
return confirm ('Are you sure you want to delete ?')

}

</script>

You Should be all set .

Hope It Helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top