Solved

bound checkbox list and setting one of the checkboxes to read only

Posted on 2003-10-21
5
1,299 Views
Last Modified: 2008-02-26
hi all,

i have a bound check box list that i want to dynamically change the appearance/format of 1 to all of the checkboxes depending upon other data.

It is a list of payment options like so:

x  Widget 9
x  Gadget 11
x  Part 14
x  Piece 15
x  Ratchet 12

If the user has already made a payment for one of these items then i want the listitem text to be different and the checkbox to either be unavailable or set to read only, so that when the page loads it will look like this:

x  Widget 9
x  Gadget 11 - PAID
x  Part 14
x  Piece 15 - PAID
x  Ratchet 12

I know i will have to set this in the code behind.

Is this possible? Can someone show me how i might do this?

In VB please!

Thanks!!

 - trevor
0
Comment
Question by:trevoray
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:naveenkohli
Comment Utility
You may not be able to do it by using bound control. You will have to populate the list manually by creating the ListItem for each data item and then modifying the text depending if PAID or not status.
0
 

Author Comment

by:trevoray
Comment Utility
ok, so let's say i don't bind it, but enter in all the widget types manually, how would i access an individual item in the code behind?

dim strgadget11 AS STRING
If such and such is true then strgadget11 = 'true'

If strgadget11 = 'true' then listitem.gadget11.text = "gadget 11 - PAID"

??

thanks!
0
 
LVL 23

Expert Comment

by:naveenkohli
Comment Utility
DO you mean accessing what checkboxes have been cheked or how to populate them..

You access each item by index... or you can use For Each syntax to get to each item in the list control.

Dim myList As ListBox

Dim myItem1 As ListItem = myList(0)

Something like that..
0
 

Author Comment

by:trevoray
Comment Utility
no, not accessing which checkboxes have been checked. assessing data in the database, seeing if they have already paid for their widget some time ago, and if the have, then doing like illustrated above and also making the checkbox 'disabled' or 'read-only'

so, i don't need to search and find out the criteria of the checkboxes, but rather the opposite, dynamically set the criteria for each checkbox.  would the best way be to just build the whole list in the behind code?  :(
0
 
LVL 23

Accepted Solution

by:
naveenkohli earned 500 total points
Comment Utility
Best would be to build the list manually in code behind. Just add the control on the page and then on load time add the items to it.
You must have some field in the table that tells you if status is PAID or not.

here is small pseudo code [sorry its C#]

foreach (DataRow row in myTable.Rows)
{
  ListItem item = new ListItem();
   string strText = row["desc"];
   if (Convert.ToBoolean(row["status"]))
   {
      strText += " - PAID";
   }

   item.Text = strText;
   myList.Items.Add(item);
}
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now