Allow Once CheckBox only in GRIDVIEW
'--allow one checkbox only in GRIDVIEW
<script type="text/javascript" lang="javascript">
function CheckOne(obj) {
var grid = obj.parentNode.parentNode.parentNode;
var inputs = grid.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox") {
if (obj.checked && inputs[i] != obj && inputs[i].checked) {
inputs[i].checked = false;
}
}
}
}
</script>
'--inside your gridview
<asp:TemplateField HeaderText="Pilih">
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" onclick="CheckOne(this)" />
</ItemTemplate>
</asp:TemplateField>
No comments:
Post a Comment