0

I have a form that contains of a gridview and a hidden panel inside an updatepanel. When I click on the gridview header, I will use ModalPopupExtender from ajax to populate the hidden panel and show a checkboxlist for users to chose and then save.

The problem that I'm having is, the selected item from checkboxlist cannot be cleared. For example, I selected first item and click save. After that ModalPopupExtender will be closed. If I click on the gridview header again, when the checkboxlist is populated, the previous selected first item clearly showed that it wasn't selected. Then I select second item from the checkboxlist to save, but this time the system will detect that the first item still selected. So on second save, it will show that I had selected first and second item.

I tried to loop all items and set selected =false but it didn't work. I also tried the below codes but no luck. Please help.

CheckBoxList.EnableViewState = false; CheckBoxList.ClearSelection();

4

2 回答 2

0

添加一个 javascript 函数以调用您单击的按钮以打开 ModalPopupExtender 将其添加到 OnClientClick

于 2013-11-01T04:25:02.507 回答
0
<script language="javascript">
    function checkListClear() {
        var chk = document.getElementById('CheckBoxList1');
        var checkBoxArray = chk.getElementsByTagName('input');
        for (var i = 0; i < checkBoxArray.length; i++)
                {
                    if (checkBoxArray[i].checked) {                          
                       checkBoxArray[i].checked = false;
                   }
                }
    }
</script>
于 2013-11-01T04:19:47.953 回答