Site Search:
Sign in | Join | Help

This Blog

4Penny offers domain names

Syndication

Tags

No tags have been created or used yet.

Archives

4Penny.net

Corey McClelland

Personal note from Ace Developer - Corey McClelland

DataGrid Confirmation Popups

DataGrids often have a delete button that removes data from the database.  There isn't, however, an immediately obvious way of making a delete confirmation popup.  By adding a javascript attribute in the datagrid ItemCreated event, we can have the standard javascript confirmation box appear.

 This html side of the page would have a template column defined something like this:

 <asp:TemplateColumn>
   <ItemTemplate>
      <asp:LinkButton ID="lnkDelete" Runat="server" />
   </ItemTemplate>
</asp:TemplateColumn>

The ItemCreated event will contain something like:

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
   Dim lnkDelete As LinkButton = CType(e.Item.FindControl("lnkDelete"), LinkButton)
   lnkDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this row?');")
End If

Comments

 

Steve Gray said:

Yoo da man

January 17, 2007 1:03 PM

Leave a Comment

(required)  
(optional)
(required)  
Add