[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2003-10-21
5
Medium Priority
?
1,309 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 2000 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

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

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…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

873 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