Dialog Box for Delete in DataGrid

D

Dan

I have a datagrid and want a dialog box to appear when user clicks on
the Delete link in the 3rd column of the grid (0 based, column 2), I
have the code:

Dim UpdateButton As LinkButton = New LinkButton()
UpdateButton = CType(e.Item.Cells(2).Controls(0), LinkButton)
UpdateButton.Attributes.Add("onclick", "return confirm('Are you
sure you want to Delete?')")

Is this the code to use and where do I put it? It does not work in the
Delete Command event. The Attributes/Dialog box works fine if I wire
it up to a button to test it - the question is, how do I wire it to
the user selected Delete hyperlink in the datagrid?

What am I missing?

Any help is greatly appreciated.

Dan
(e-mail address removed)
 
D

Dan French

Alvin,

Thank you, but when I try that I get:

Specified argument was out of the range of valid values. Parameter name:
index

error. Any suggestions?

Dan
 
D

Dan French

Alvin

Got It!!

If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <>
ListItemType.Footer Then

Dim deleteButton As LinkButton = e.Item.Cells(2).Controls(0)
deleteButton.Attributes.Add("onclick", "return confirm('Are
you sure you want to Delete?')")

in the databound event handler, works like a charm

Thanks for your response and help

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top