Solved

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

Posted on 2003-10-21
5
1,305 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
[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 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

728 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