Solved

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

Posted on 2003-10-21
5
1,301 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
ID: 9593719
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
ID: 9593758
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
ID: 9593785
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
ID: 9593938
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
ID: 9594001
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
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 …

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