473,467 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Shopping Cart checkboxes

36 New Member
I'm trying to create a simple shopping cart, so when the multiple checkboxes on the UI are checked the objects are added to the database. My question is how would I handle checking to see which checkboxes are checked from the multiple checkboxes and what is the best method of saving the objects to storage.
Jul 10 '07 #1
3 1394
programmerboy
84 New Member
I'm trying to create a simple shopping cart, so when the multiple checkboxes on the UI are checked the objects are added to the database. My question is how would I handle checking to see which checkboxes are checked from the multiple checkboxes and what is the best method of saving the objects to storage.
I hope you are using vb.net. Here is something you can try using.

Expand|Select|Wrap|Line Numbers
  1. Dim ctrlCol As ControlCollection = Me.Controls
  2. Dim count x As Integer
  3. Dim strChkBoxText,strChkBoxName as String
  4. Dim checked as boolean
  5. count = ctrlCol.Count
  6.  
  7. For x = 0 To count - 1
  8.     ctl = ctrlCol.Item(x)
  9.     If TypeOf (ctl) Is CheckBox Then
  10.        Dim a As CheckBox
  11.        a = CType(ctl, CheckBox)
  12.  
  13.        ctl.Text = "" 'will set the text for that control
  14.        strChkBoxText = ctl.Text 'will get the text for that control
  15.        strChkBoxName = ctl.Name  'will get the text for that control
  16.        checked = aCheckBox.checkd 'will check if checkbox is checked
  17.     End If
  18. Next x
Jul 10 '07 #2
wbosw
36 New Member
I'm using C#, but I will look this over carefully to see if I can covert the code.

Thanks,
wbosw
Jul 10 '07 #3
wbosw
36 New Member
I hope you are using vb.net. Here is something you can try using.

Expand|Select|Wrap|Line Numbers
  1. Dim ctrlCol As ControlCollection = Me.Controls
  2. Dim count x As Integer
  3. Dim strChkBoxText,strChkBoxName as String
  4. Dim checked as boolean
  5. count = ctrlCol.Count
  6.  
  7. For x = 0 To count - 1
  8.     ctl = ctrlCol.Item(x)
  9.     If TypeOf (ctl) Is CheckBox Then
  10.        Dim a As CheckBox
  11.        a = CType(ctl, CheckBox)
  12.  
  13.        ctl.Text = "" 'will set the text for that control
  14.        strChkBoxText = ctl.Text 'will get the text for that control
  15.        strChkBoxName = ctl.Name  'will get the text for that control
  16.        checked = aCheckBox.checkd 'will check if checkbox is checked
  17.     End If
  18. Next x





I'm using C#, but I will look this over carefully to see if I can covert the code.

Thanks,
wbosw
Jul 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Don Grover | last post by:
I am retrieving costs and product id's from a sql db. and need to build a shopping cart around it. How do I store the selected items and qty req so I can move into another catalog and total up as...
2
by: Paul Bruneau | last post by:
Hi, I hope someone can help me make a working shopping cart, as a learning tool. If I have a "Product Demo" html page with a "Buy Me" button, there must be a simple javascript method of...
1
by: madison | last post by:
Hi, I am trying to start a website using paypals shopping cart function. If i have 10 items and they sell out, how do I make it so the item is then listed as sold out. The next person would not...
1
by: Jia Sun | last post by:
hello , everybody , i need a similar program , just like fancyimport.com if possible, pls contact me ,thank you very much . inchina@gmail.com
1
by: Adil Akram | last post by:
I have created a site shopping cart in ASP.net. I am using ASP session object's SessionID on non SSL connection to track session. While adding products to cart DB I insert product and SessionID...
2
by: G.E.M.P | last post by:
High Level Session Handling Design for a Shopping cart 0) What am I missing? 1) How does OSCommerce do it? I'm thinking about building a shopping cart from scratch, using a library of dynamic...
7
by: isaac2004 | last post by:
hi i have a basic asp page that acts as an online bookstore. on my cart page i am having trouble generating 3 numbers; a subtotal, a shipping total, and a final price. here is my code i would...
1
by: jecha | last post by:
I'm implementing a shopping cart but am having a problem in checking out a person who has added item in his/her shopping busket.The code for the checkout.php script is given below <?...
3
by: Paulo | last post by:
Hi, beginner on asp.net 2.0 C# VS 2005, how can I use the shopping cart concept on my application? When the user clicks add item, it will be stored on some storage format, I dont know what is the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.