Datagrid confirm('some msg');

  • Thread starter Thread starter jayuya
  • Start date Start date
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
 
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
 
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
 
Back
Top