开发者

how to use checkbox list as radio button

开发者 https://www.devze.com 2023-03-04 12:56 出处:网络
I have checkbox list, values are extacting from DB by button 开发者_开发知识库click. the vaues are ALL,Produc1,Product2. by default all is selected if i select Product1 \"ALL\" checkbox should uncheck

I have checkbox list, values are extacting from DB by button 开发者_开发知识库click. the vaues are ALL,Produc1,Product2. by default all is selected if i select Product1 "ALL" checkbox should uncheck.

<asp:CheckBoxList ID="chkProductOption" RepeatColumns="2" runat="server" 
                    AutoPostBack="false"  >                      
                </asp:CheckBoxList>

pls share ur ideas


You don't.

Use a RadioButtonList and style the radio buttons as checkboxes.


After clarification, this is what I would do:

In javascript, attach to the click or change event of the checkboxes, and if any of the products are selected, uncheck the ALL checkbox.

Of course, since this is client side, you would have to validate on the server side.


Definitely there should be a custom logic involved because as far as I know no check box list has such a behavior.

two ways has came to my mind that I'd like to suggest:

First, you can have an event handler in place that listens to the check box list and if the selected item has changed checks to see if it's the All item or not and if that is it will check all other items (or uncheck them ) This can be done using a javascript or if the control post back its state every time its state has changed then you can have it on code behind.

Second, you can have another single check box next to your check box list that says " or select All " for example and if it's checked it disable the check box list.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号