Thursday, 13 June 2013

how to create checkbox single selection in grideveiw using jquery in asp.net

 <asp:TemplateField HeaderText="Default">
                                    <ItemTemplate>
                                    <asp:CheckBox id="cbdefault" runat="server" Checked='<%#Eval("Default") %>' onclick="check(this)" />
                                    </ItemTemplate>
                                </asp:TemplateField>

script
 <script language="javascript" type="text/javascript">
function check(source) {
        var isChecked = source.checked;
        var ids = {
            grid: "<%= gvdetails.ClientID %>"
        }
        $("#" + ids.grid + " input[id*='cbdefault']").each(function (index) {
            $(this).attr('checked', false);
        });
        source.checked = isChecked;
    }
  </script>

No comments:

Post a Comment