Solved

Disable Items in Checkbox List

Posted on 2008-10-22
5
350 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 125 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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

737 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