Solved

Disable Items in Checkbox List

Posted on 2008-10-22
5
340 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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