Pages

Wednesday, April 1, 2009

confirmation message on delete in a gridview

protected void gridOverview_OnRowDataBound(object sender, GridViewRowEventArgs e)
//Add delete msgbox to each row containing field
//information to identify the row
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// reference the Delete ImageButton
ImageButton ib = (ImageButton)e.Row.FindControl(“ibDelete”);
ib.Attributes.Add(“onclick”,“javascript:return ” +
confirm(’Are you sure about deleting ” +
DataBinder.Eval(e.Row.DataItem, ColomnName) + “?’);”);
}
}

OR


Add New Client Click property of button
return confirm(’Are you sure about deleting ”);

OR
Use Ajax Extender for confirmation box
<asp:TemplateField HeaderText=”Delete” >
<ItemStyle CssClass=”grid-column-buttons” />
<ItemTemplate>
<asp:ImageButton ID=”ibDelete” runat=”server”
CausesValidation=”False” CommandName=”Delete”
ImageUrl=”~/Images/icon-delete.gif” />
<ajaxToolkit:ConfirmButtonExtender ID=”ConfirmBtExt1″
runat=”server” TargetControlID=”ibDelete”
ConfirmText=’Are you sure about deleting this record?’ />
ItemTemplate>
asp:TemplateField>


1 comment:

Bhaskara said...

Good post about confirmation button using different technologies

ShareThis

Welcome

Welcome to Rajesh Prajapati, asp.net blog.
Here you can find some useful code and information about asp.net., c#, VB.net, SQL Server, Web Service, Web Designing etc