DataGrid and JavaScript

  • Thread starter Thread starter Feniks
  • Start date Start date
F

Feniks

I have a DataGrid with data coming out of a database and I can execute
delete, update and other operations, it all works fine.
However, I would like a javascrip confirm window to come out whenever I want
to delete a recordset from a database, so the recordset will be deleted
only if a user clicks "OK" on that window. Otherwise, if a user clicks
"CANCEL", nothing will be deleted.
How do I do that?
Thanks!
 
That's right and you helped me! Thanks!

Jenny K said:
Feniks said:
I have a DataGrid with data coming out of a database and I can execute
delete, update and other operations, it all works fine.
However, I would like a javascrip confirm window to come out whenever I want
to delete a recordset from a database, so the recordset will be deleted
only if a user clicks "OK" on that window. Otherwise, if a user clicks
"CANCEL", nothing will be deleted.
How do I do that?
Thanks!

I'm guess you're clicking on a LinkButton or something. Just add some DHTML
to whatever it is you're clicking. I usually add code similar to the
following to the ItemDataBound event of my datagrids.

LinkButton lbVerify;
lbVerify = (LinkButton)tdMyButtonColumn.Controls[0];
lbVerify.Attributes.Add("onclick","if(confirm("Are you sure?')){return
true;}else{return false;}");
 
Back
Top