views:

791

answers:

5

i have a CheckBoxList with a list of services that the user can execute... some of this services can't be executed with some of the others, some services can only be executed alone etc..

All this rules are stored in my database.

Is there anyway for me to disable/enable (make unclikable) checkboxlist items that can't be executed together, in the event of clicking(checking/unchecking) a service?

I just can't figure it out, Since I even don't know how to get the Id of the last clicked item..

A: 

No, you will need to handle this yourself in one of the list box events.

eschneider
Probably better to have different list boxes for non-compatible items. A user may get annoyed if you change/prevent selections...
eschneider
A: 

There is no built in method to get the last clicked item. You could use iteration which fires on CheckBoxList1.SelectedIndexChanged, but this is time-consuming for large lists and many database hits.

Matthew Jones
A: 

You will need to capture the event which fires when a button is selected; when you get the event for a specific button being selected, you can set the other buttons which it is exclusive to to be Disabled.

McWafflestix
+1  A: 

Cant you use the selectedIndexChanged event on each of the individual checkboxes?

the sender should be the last clicked checkbox and they can all invoke the same handler method.

Adam Fox
+1  A: 

checkBox1.Visible = false;

if they can't see it, they can't click it.

see_sharp_guy
It is a CheckBoxList, not a single checkbox
Vitor Reis
well then why not simply shift to a number of individual checkboxes.that way you'll also be albe to tell which ones event fired.you can hold them all in an arraylist and still conenct them to you DB.
see_sharp_guy