i want that after clicking a hyperlink "delete" located at each row of my gridview which lists trainings that i check if a trainee wasn't assign to the training concerned by the delete
For adding a delete prompt on a datatable (looks like its going to be a datagrid in UI), you would need to bind the javascript to prompt for this alert during the ItemDataBound/RowDataBound event of the datagrid.
In this event, while the data is binded row by row - add something like:
LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
l.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete this record')");
Alternatively,
if the link button in ItemTemplate of datagrid has OnclientClick event exposed (which is present in ASP.NET2.0 onwards), you can add something like:
OnClientClick = 'return confirm("Are you sure you want to delete this entry?");'
Refer:
MSDN: Adding Client-Side Confirmation when Deleting[
^]
hen display a alert message if there is any trainee assigned to the training and if not to delete the training
For this, just show the thing in a label text. Showing it in an alert window would not be good idea for the purpose. Once DB update fails, show that as a red label text on the page.