Datagrid confirm('some msg');

J

jayuya

Can some one point me or show me some sample code on how
to confirm a delete when the user selects an item from the
datagrid.

I am able to do so only when is a push type button, but I
want to put in the grid the text word "Delete" like a
link...and use the confirm as well...

thanks
jayuya
 
D

David Waz...

No problem:

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound

Dim item As DataGridItem = e.Item

Dim label As String = "Carrier"

Dim value As String = item.Cells(2).Text

item.Cells(DELETE_COL_NUM).Attributes.Item("onClick") = DeleteConfirmJava(label, value) ' DELETE_COL_NUM is the column to affect...



End Sub

Public Function DeleteConfirmJava(ByVal Label As String, ByVal Value As String) As String

Dim OpInfo As String

OpInfo = "\t DELETE <Object>:\n"

OpInfo &= "\t============\n"

OpInfo &= "<VALUE>\n"

OpInfo &= "\nYou have asked to delete this <Object>.\n"

OpInfo &= "Are you SURE this is what you want?"

OpInfo = "return confirm('" & OpInfo & "');"

' - put in label and values

OpInfo = Regex.Replace(OpInfo, "<Object>", Label, RegexOptions.IgnoreCase)

OpInfo = Regex.Replace(OpInfo, "<Value>", Value, RegexOptions.IgnoreCase)

Return OpInfo

End Function
 
J

jayuya

David,

Thanks a lot, It worked great...:)

jayuya
-----Original Message-----
No problem:

Private Sub DataGrid1_ItemDataBound(ByVal sender As
Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
Dim item As DataGridItem = e.Item

Dim label As String = "Carrier"

Dim value As String = item.Cells(2).Text

item.Cells(DELETE_COL_NUM).Attributes.Item("onClick") =
DeleteConfirmJava(label, value) ' DELETE_COL_NUM is the
column to affect...
End Sub

Public Function DeleteConfirmJava(ByVal Label As String,
ByVal Value As String) As String
 

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
474,082
Messages
2,570,588
Members
47,209
Latest member
Ingeborg61

Latest Threads

Top