Hi ,
Please refer the below sample code for your reference and implement it as per your reuirement in your code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
window.onload = function () {
document.getElementById("hfcheckedValue").value = "";
var checkboxes = document.getElementById("chkFruits").getElementsByTagName("INPUT");
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].onclick = function () {
var checked = false;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
var checkedValue = document.getElementById("hfcheckedValue").value.trim();
checked = true;
if (checkedValue != "" && checkboxes[i].value == checkedValue) {
}
else {
document.getElementById("hfcheckedValue").value = checkboxes[i].value;
break;
}
}
}
if (!checked) {
document.getElementById("hfcheckedValue").value = "";
} else {
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
if (document.getElementById("hfcheckedValue").value.trim() != checkboxes[i].value) {
checkboxes[i].checked = false;
}
}
}
}
};
}
};
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="chkFruits">
<tr>
<td>
<input id="chkFruits_0" type="checkbox" name="chkFruits$0" value="1" /><label for="chkFruits_0">Mango</label>
</td>
</tr>
<tr>
<td>
<input id="chkFruits_1" type="checkbox" name="chkFruits$1" value="2" /><label for="chkFruits_1">Orange</label>
</td>
</tr>
<tr>
<td>
<input id="chkFruits_2" type="checkbox" name="chkFruits$2" value="3" /><label for="chkFruits_2">Banana</label>
</td>
</tr>
<tr>
<td>
<input id="chkFruits_3" type="checkbox" name="chkFruits$3" value="4" /><label for="chkFruits_3">Apple</label>
</td>
</tr>
<tr>
<td>
<input id="chkFruits_4" type="checkbox" name="chkFruits$4" value="5" /><label for="chkFruits_4">Papaya</label>
</td>
</tr>
</table>
<input type="hidden" name="hfcheckedValue" id="hfcheckedValue" />
</div>
</form>
</body>
</html>
Demo
You can replace the html controls with asp controls.
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem Text="Mango" Value="1"></asp:ListItem>
<asp:ListItem Text="Orange" Value="2"></asp:ListItem>
<asp:ListItem Text="Banana" Value="3"></asp:ListItem>
<asp:ListItem Text="Apple" Value="4"></asp:ListItem>
<asp:ListItem Text="Papaya" Value="5"></asp:ListItem>
</asp:CheckBoxList>
<asp:HiddenField ID="hfcheckedValue" runat="server" />