Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am using the following code to de

Status
Not open for further replies.

raynkel

Programmer
Oct 24, 2002
23
US
I am using the following code to delete a row in a datagrid.

Private Sub DataGrid1_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand

Dim Index As Integer
Index = e.Item.ItemIndex

DsBCABD1.BCABD_Reg.Rows(index).Delete()
DaBCABDReg.Update(DsBCABD1)
DaBCABDReg.Fill(DsBCABD1)

DataGrid1.DataBind()

End Sub

It works fine. But, I would like to include a "Are You Sure??" somehow.
I have no clue!!
Any help would be great
Thanks
Ray
 
Two ways to do this.

1) A (Child) non-modal Web form with confirmation dialogue, providing a QueryString containing the user response back to the (Parent) web form with the datagrid etc on it.

2) Client side script, (Javascript), making use of window.confirm, which provides a Modal Yes / Cancel confirmation dialogue. Add an attribute to the Web Button, to fire the confirmation dialogue in the client side on-click event. When you click the Web Button, before the form posts back , the client side event ocurs giving a Modal confirmation dialogue to the user. A response of Yes will allow the post back, a response of Cancel prevents the post back from the Web Button.

I've only used Method 2, as Method 1 is non-modal, can be completely ignored by the user and if you definitely want to get a response without having to produce a lot of code, I find Method 2 easier. In your case though you'll have to add an attribute for the client side event to each delete Button control in your datagrid.

Rhys
Thought out... Maybe,
Opinionated... Probably
But it is only an opinion!
 
Thanks very much. I searched forever trying to find that. It works like a charm.

Ray
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top