Reputation: 17495
How can I get my CheckBoxList
to have three possible states ? More precisely, is there a way to have three possible states for each checkbox : checked, unchecked, undefined (in most GUIs this is represented as a full square).
Alternatively, do you recommend another control that would meet these needs ?
UPDATE : Ok, given that HTML does not support tri-state checkboxes, I'm looking for a way to 'CSS' (color fill, highlight, etc...) the checkboxes of the items that are in that 'undefined' state from my server point of view.
Upvotes: 1
Views: 1851
Reputation: 17495
I have decided to use CheckBoxList anyway, since I need two states accessible by the user, and a third one not accessible by the user but to display inconsistencies.
The way I have solved this is through Javascript + CSS. Some bits of ideas here: http://css-tricks.com/indeterminate-checkboxes/
Upvotes: 0
Reputation: 3385
Not all GUIs represent undefined as a full square. That's why it's going to be clearer to use one of the following:
1. Radio boxes
2. Dropdown
3. ListBox
Upvotes: 5
Reputation: 173
You could just extend or derive from the CheckBoxList and create your own custom control from it.
Here is an example of this.
Upvotes: 2
Reputation: 27022
Any asp.net control you use will ultimately need to be rendered as an html checkbox, which can only be checked or unchecked. You could use a data- attribute to keep track of extra state behind the scenes, but that wouldn't be reflected in the UI.
I suppose you could also implement a client-side solution using JavaScript and CSS as well.
Upvotes: 2