<script type="text/javascript"> <!-- function Check_Click(objRef) { //Get the Row based on checkbox var row = objRef.parentNode.parentNode; //Get the reference of GridView var GridView = row.parentNode; //Get all input elements in Gridview var inputList = GridView.getElementsByTagName("input"); for (var i = 0; i < inputList.length; i++) { //The First element is the Header Checkbox var headerCheckBox = inputList[0]; //Based on all or none checkboxes //are checked check/uncheck Header Checkbox var checked = true; if (inputList[i].type == "checkbox" && inputList[i] != headerCheckBox) { if (!inputList[i].checked) { checked = false; break; } } } headerCheckBox.checked = checked; } function checkAll(objRef) { var GridView = objRef.parentNode.parentNode.parentNode; var inputList = GridView.getElementsByTagName("input"); for (var i = 0; i < inputList.length; i++) { var row = inputList[i].parentNode.parentNode; if (inputList[i].type == "checkbox" && objRef != inputList[i]) { if (objRef.checked) { inputList[i].checked = true; } else { if (row.rowIndex % 2 == 0) { row.style.backgroundColor = "#C2D69B"; } else { row.style.backgroundColor = "white"; } inputList[i].checked = false; } } } } //--> </script>
<HeaderTemplate> <asp:CheckBox ID="chkAll" runat="server" onclick="checkAll(this);" AutoPostBack="true" OnCheckedChanged="CheckBox_CheckChanged" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="chk" runat="server" onclick="Check_Click(this)" AutoPostBack="true" OnCheckedChanged="CheckBox_CheckChanged" /> </ItemTemplate>
Thanks and Regards V.SaratChand Show difficulties that how difficult you are
Login to post response