Monday 2 July 2012

GridView Delete Confirmation

<asp:GridView ID="GridView_Main" runat="server" ...>
<Columns>
.....

<asp:CommandField ButtonType="Image" DeleteImageUrl="Images/Delete_16.gif" ShowDeleteButton="true" CausesValidation="true" >
<HeaderStyle Width="16px" />
<ItemStyle Width="18px" />
</asp:CommandField>
</Columns>

</asp:GridView>



Protected Sub GridView1_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView_Main.RowDataBound
.....

Dim ImagButton_Delete As ImageButton = e.Row.Cells(6).Controls(0)
ImagButton_Delete.OnClientClick = "if (!confirm('Delete?!')) return;"
.....

End Sub

No comments:

Post a Comment