I have a grid in the update panel (web forms). There is a heading in the grid view, so when you click on the heading, it checks all the checkboxes below it, for example:
<asp:TemplateField> <HeaderTemplate> <asp:CheckBox ID="HeaderLevelCheckBox" runat="server" onclick="toggleSelection(this);" ToolTip="Select / Deselect all rows?" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="chkSelector" runat="server" ToolTip="Select row?" /> </ItemTemplate> </asp:TemplateField>
Pay attention to the function call onclick="toggleSelection(this);" which looks like this:
function toggleSelection(source) { $("#MainContent_gvCG input[id*='chkSelector']").each(function (index) { $(this).attr('checked', source.checked); if (source.checked) $(this).css({ backgroundColor: "yellow" }); else $(this).css({ backgroundColor: "" }); }); }
This is declared immediately after document.ready in the script tag. When I initially load the page and click on the headercheckbox button, all the rows in the gridview are also selected (great ... works). If I uncheck it, all lines will not be marked (big work). The very moment I click on it again, the user interface does not change (all elements are not checked as they should be).
I was curious and after checking the markup, which was also right, when I click on the title to check it for true, I get the checked line items:
<input id="MainContent_gvCG_chkSelector_5" type="checkbox" name="ctl00$MainContent$gvCG$ctl08$chkSelector" style="background-color: rgb(255, 255, 0);" checked="checked">
And when I remove his title, he answers like this:
<input id="MainContent_gvCG_chkSelector_5" type="checkbox" name="ctl00$MainContent$gvCG$ctl08$chkSelector" style="">
My problem is that the user interface does not change, that is, the flags do not appear as checked, even if the markup shows it as being checked. Is it due to what's inside the update panel?
What can I do to fix this?