When click on delete link-button in gridview, Confirmation Box not appeared. I write this code but i don't know why it's not working...

<asp:GridView ID="gvwAuctionExport" runat="server" AutoGenerateColumns="false" OnRowCommand="gvwAuctionExport_RowCommand" OnRowDataBound="gvwAuctionExport_RowDataBound"  OnRowDeleting="gvwAuctionExport_RowDeleting">
<Columns>
    <asp:TemplateField>
        <ItemTemplate>
            <div class="btn-group btn-group-xs" id="bgroup">                                                                                 
                <asp:LinkButton ID="lnkInspectionDelete"  runat="server" Text="Delete" CssClass="btn btn-danger" CommandArgument='<%# Eval("inspection_id") %>' CommandName="Delete"></asp:LinkButton>
            </div>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="address" HeaderText="Address" />
    <asp:BoundField DataField="city" HeaderText="City" />
    <asp:BoundField DataField="state" HeaderText="State" />
</Columns>

protected void gvwAuctionExport_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Delete")
    {
        int InspectionID = Convert.ToInt32(e.CommandArgument);
        string status = string.Empty;
        status = DACls.DeleteInspectionByID(InspectionID);
    }
}    
protected void gvwAuctionExport_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton l = (LinkButton)e.Row.FindControl("lnkInspectionDelete");
            l.Attributes.Add("onclick", "javascript:return " +
            "confirm('Are you sure you want to delete this record");
        }
    }
protected void gvwAuctionExport_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    bindGridView();
}
public void bindGridView(){
        DataSet DS = new DataSet();
        SqlConnection DBCon = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString);
        SqlCommand Cmd = new SqlCommand("USP_Inspection_Export", DBCon);
        Cmd.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter AHadp = new SqlDataAdapter(Cmd);
        AHadp.Fill(this.DS);
        DataTable dt = DS.Tables[0];
        this.gvwAuctionExport.DataSource = dt;
        this.gvwAuctionExport.DataBind();
}

When i click on delete button and check from debugger it is not going to GridView RowDataBound function scope. i don't know what happening here?

Related posts

Recent Viewed