?
Solved

Disable Items in Checkbox List

Posted on 2008-10-22
5
Medium Priority
?
364 Views
Last Modified: 2012-05-05
Hi

I have a checkboxlist which is populated from a database. I am also added a item to the checboxlist called any:
cblFundTypeAdvised.Items.Insert(0, New ListItem("Any", "-1"))

What i am trying to do is if there is a -1 value in the database then it disables all other items in the checkbox list except for this one (the Any one which is added manually)

Any ideas?
0
Comment
Question by:patelajk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
AmarIs26 earned 500 total points
ID: 22774830
If you are doing databind then you can set the visible property to false or true depending on the value column in the dataitem. I forget the exact expression but something like this
Enable='<% Eval("valueColumn") != -1 %>'
however if you are looping throw the items manually and adding then to the Checkbox list then you can do this in the prerender event
 

for(int i=0; i< cblFundTypeAdvised.Items.Count; i++)
{     
   ListItem item =  cblFundTypeAdvised.Items[i];
   if(item.Value == "-1")
   {
      item.Enabled = false;
   }
}

Open in new window

0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22774841
Sorry you also need to use this if statement
if(item.Text != "Any" && item.Value == "-1")

0
 

Author Comment

by:patelajk
ID: 22774898
tried this but it disables the ANY checkbox litem only.... i want it to disable the other checkbox items and leave the ANY enabled
0
 
LVL 6

Expert Comment

by:AmarIs26
ID: 22775123
Well the above should do it. If current item is not "Any" and value is "-1" then it should disable.
You can try putting the else statement
else
{
  item.Emabled = true;
}
0
 

Author Closing Comment

by:patelajk
ID: 31508673
Got me started.... thanks for that
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question