jeudi 19 mars 2020

C# asp.net checkbox not firing when unchecked

I have found this question a few places but no solutions...

I have a checkbox in a gridview:

<asp:TemplateField HeaderText="Closed?">
    <ItemTemplate >
        <asp:CheckBox ID="Status_CB"  runat="server" AutoPostBack="true" 
            OnCheckedChanged="Status_CB_CheckedChanged" 
            EnableViewState="true" ViewStateMode="Enabled" 
            Checked='<%# Convert.ToString(Eval("cStatus")) == "1" ? true : false %>'/>
    </ItemTemplate>
</asp:TemplateField>

codebehind:

protected void Page_Load(object sender, EventArgs e) {
    if (!int.TryParse(Session["FacilityID"].ToString(), out FId)) {
        FId = 0;
    }
    if (!Page.IsPostBack) {
        if (!string.IsNullOrEmpty(Request.QueryString.Get("WorkCenter"))) {
            wc = Request.QueryString.Get("WorkCenter");
            WorkcenterHeader.InnerText = wc + " Schedule ";
            HiddenWorkCenter.Value = c;
        }
        if (!SQLHasData()) {
            SavePrioritiesToSQL();
        }
        BindGrid();
    }
}
protected void Status_CB_CheckedChanged(object sender, EventArgs e) {
    CheckBox cb = (CheckBox)sender;
    GridViewRow row = (GridViewRow) cb.Parent.Parent;
}

When i check the box originally, it works. When i uncheck it, the breakpoint i have on the first line of Status_CB_CheckedChanged does not fire at all.

What am i missing any one know?




Aucun commentaire:

Enregistrer un commentaire