Add javascript Alert for Delete Linkbutton In Gridview

http://www.dotnetspider.com/resources/23154-Adding-Javascript-Alert-for-Delete-button.aspx

Event of GridView

OnRowDataBound=”GridView1_RowDataBound”

Code behind:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //add  javascript alert for delete link button
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton l = (LinkButton)e.Row.FindControl(“lbtnDeleteGrid”);
            l.Attributes.Add(“onclick”, “return confirm(‘Ban có muốn xóa ngày này không ?’)”);
        }

    }

Advertisements