A good feature to have as part of any GridView is the ability to delete an item from the grid.
If the grid is dynamically linked to a DataSet then the buttons must be generated at run-time. This causes a problem if you want to perform some kind of confirmation to the delete operation so that the user doesn't simply delete an item by mistake.
The confirmation is easily achieved using an AJAX Tool Kit Extender control called the Confirm Button Extender Control. The problem is getting the control associated with the dynamically generated buttons.
The only way to achieve this would be to actually include the Confirm Button Extender Control definition as part of your template definition for the Delete button.
the following code demonstrates:
<Columns>
<asp:TemplateField HeaderText="Delete Item">
<ItemTemplate>
<asp:LinkButton
ID="delButton"
runat="server"
OnClick="delButton_Click">Delete</asp:LinkButton>
<asp:ConfirmButtonExtender
ID="cbeDelete"
runat="server"
TargetControlID="delButton"
ConfirmText="Are you sure you want to delete this item"
ConfirmOnFormSubmit="true"></asp:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment