Navigation

Search

Categories

On this page

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 112
This Year: 50
This Month: 0
This Week: 0
Comments: 0

Sign In

 Monday, November 12, 2007
Monday, November 12, 2007 8:41:08 PM (Eastern Standard Time, UTC-05:00) (  |  )

If you want to add a client-side prompt to a GridView's delete function, so that the user has a another chance to prevent it, one simple way is to add a template field to the GridView with a LinkButton whose CommandName is set to "Delete" and whose OnClientClick property is set to something like 'return confirm("Are you sure???");'

<asp:GridView ID="GridView1" runat="server" DataKeyNames="id" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
OnClientClick='return confirm("Are you sure you want to delete this entry?");'
Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):