Private Sub myGridView_RowDataBound(sender As Object, e As GridViewRowEventArgs)
Dim btnDelete As Button = CType(e.Row.FindControl("btnDelete"),Label)
IF Not IsNothing(btnDelete) Then
btnDelete.Attributes.Add("Onclick", "return confirm('Do you delete...?');")
End IF
End Sub
// btnDelete คือปุ่ม Delete
Date :
2009-01-19 15:58:59
By :
webmaster
No. 2
Guest
Code (C#)
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
l.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete this record " +
DataBinder.Eval(e.Row.DataItem, "CategoryID") + "')");
}
}
Code (VB.NET)
Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim l As LinkButton = DirectCast(e.Row.FindControl("LinkButton1"), LinkButton)
l.Attributes.Add("onclick", "javascript:return " & "confirm('Are you sure you want to delete this record " & DataBinder.Eval(e.Row.DataItem, "CategoryID") & "')")
End If
End Sub