c# - Asp.net Checkbox issues after postback -
this asp.net project c#
i have gridview has checkbox column. user selects row clicking appropriate checkbox. can act on row doing various things (mostly button clicks). problem having when user clicks button, gridview refreshed. of time consists of row being deleted. when user goes select checkbox (another row in gridview) act upon, can briefly see check box , checkbox unchecked or checkbox below 1 wanting select gets checked. when occurring, oncheckedchanged not fire. when refresh page, selecting , deselecting checkboxes works intended without issues whatsoever.
just few sidenotes:
- i doing row highlighting using javascript based upon checkbox selected. (i can provide code if needed)
i ensuring 1 checkbox selected @ time using code below under checkchanged event:
checkbox activecheckbox = sender checkbox; foreach (gridviewrow rw in gridview1.rows) { checkbox chkbx = (checkbox)rw.findcontrol("rowlevelcheckbox1"); if (chkbx != activecheckbox) { chkbx.checked = false; } else if (chkbx == activecheckbox && (chkbx.checked != false && activecheckbox.checked != false)) { chkbx.checked = true; } }i binding gridview in codebehind in page load within if (!ispostback)
- before ask, yes have set
autopostback="true"on checkbox
when button clicked setting checkbox.checked = false, when debug , check checkboxes in gridview on page load, after code has been executed, still shows 1 checked.
why behavior happening?
Comments
Post a Comment