Use this sample code below
Protected Sub gvrecords_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
'getting username from particular row
Dim username As String = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "UserName"))
'identifying the control in gridview
Dim lnkbtnresult As LinkButton = DirectCast(e.Row.FindControl("lnkdelete"), LinkButton)
'raising javascript confirmationbox whenver user clicks on link button
lnkbtnresult.Attributes.Add("onclick", "javascript:return ConfirmationBox('" & username & "')")
End If
End Sub
<script type="text/javascript">
function ConfirmationBox(username) {
var result = confirm('Are you sure you want to delete '+username+' Details' );
if (result) {
return true;
}
else {
return false;
}
}
</script>