Click here to Skip to main content
Click here to Skip to main content

Shopping Cart using C#.NET, Web Forms and SQL Server

, 20 Apr 2004
Rate this:
Please Sign up or sign in to vote.
Shopping cart using C#.NET, Web Forms and SQL Server.


This application is a Shopping Cart where users can select items and place an order. I have added the features of login, and adding new users if user does not exist. Validations are performed wherever needed like email format validation, zipcode etc.

Fig. 1

Database: For the purpose, I have used the NorthWind database and SQL Server.

The two main tables used are:

  1. Products table
  2. Order Details table.

I have used two classes:

public class CartRow
    public string id;
    public string name;
    public string price;
    public string items;
public class Cart
    public System.Collections.ArrayList list = new ArrayList(20);

The two main web-forms are Main.aspx and CheckOut.aspx. Main.aspx contains a grid showing all items present in the products table along with the price per unit and the quantity per unit. Fig 1 shows the Main.aspx page, where user can select items from the products grid (left). As he selects an item, it is added to his cart and the item is displayed in the right panel. The total price is displayed in the label above. As the user adds more items to his cart, the recalculated price is shown. Upon clicking the clear cart button, the cart gets empty.

If the user now wants to finalize the order and presses the CheckOut button, he is redirected to the Login.aspx page (Fig 2). I have set the default username as “user” for the sample and password is “u”.

Fig 2.

And finally, the user is asked to enter the Credit Card number, billing PIN code and his email address. It does the client side validations and then confirms the order placed by sending a mail to the user as shown in (Fig 3).

And the order is finalized. For more advanced shopping cart, this information plus the item information has to be stored in some database.

Fig 3


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
No Biography provided

Comments and Discussions

AnswerRe: Very bad Article Pinmemberdoris from South Africa8-Aug-13 13:06 
QuestionAdd To Cart Pinmemberfahad.13-Oct-12 3:11 
Questiondatabase Pinmemberfahad.12-Oct-12 20:02 
Questionits not working Pinmemberfaezajackson29-Sep-12 19:33 
QuestionRequest for Database PinmemberMember 843501415-Sep-12 4:12 
QuestionRequire database PinmemberMember 93439958-Aug-12 5:26 
QuestionRequest for database and code PinmemberAtul.Sharma0088-Aug-12 0:10 
QuestionRequest for database PinmemberSteve Pearson17-Jun-12 15:39 
AnswerRe: Request for database and code Pinmemberktnotoch3-Feb-13 21:48 
Questionrequest for the database PinmemberMark Norman11-Jun-12 4:18 
QuestionRegarding Database Pinmemberfahedk4-Jun-12 23:08 
GeneralMy vote of 2 Pinmembersaeedm1227-Feb-12 11:19 
Questiondatabase Pinmemberdurllavi14-Feb-12 23:07 
Questiondatabase Pinmembervinay chauhan4204-Feb-12 19:44 
Questiondatabase Pinmembervarsti30-Jan-12 2:46 
Questionhi Pinmembersaranyajana22-Jan-12 22:43 
Questiondatabase Pinmembermoeym9-Jan-12 22:50 
QuestionDAtabase attachment Pinmembermeestersumit26-Dec-11 4:07 
GeneralMy vote of 5 Pinmembermeestersumit26-Dec-11 4:06 
QuestionDatabase Pinmemberpayam100025-Dec-11 5:52 
QuestionDatabase Pinmemberpayam100025-Dec-11 5:32 
GeneralRequest for database PinmemberMember 848659714-Dec-11 0:51 
Questionhi Pinmembershirin_k197-Dec-11 21:33 
Questionshopping cart Pinmemberkanika bhagat7-Dec-11 3:55 
QuestionRequest for Database PinmemberAlifawad4092-Dec-11 22:57 
Questionrequest for database Pinmembermage1628-Nov-11 11:22 
QuestionRequest for database Pinmemberfacelesslucifer19-Nov-11 22:14 
Questiondatabase Pinmembersarita khotani12-Nov-11 7:42 
Generaldatabase PinmemberMember 39994768-Nov-11 9:38 
QuestionDatabase PinmemberDinesh Balendran25-Sep-11 22:06 
Questioneshopping PinmemberMember 816773617-Aug-11 5:07 
QuestionPlease send Database Details which you used to create Shopping cart Pinmemberguru4IAS30-Jun-11 1:39 
GeneralDo you have a simple shopping cart in using VB code Pinmemberaradhakrishnan4-Feb-11 14:38 
Generalrequesting to send database PinmemberLakshmisaraswathi18-Jan-11 21:23 
GeneralRe: requesting to send database PinmemberDarshanGowda00917-Aug-11 20:52 
Generalpls send me database Pinmemberhellovatsu1-Dec-10 6:04 
GeneralRe: pls send me database PinmemberDGamer2-Dec-10 10:17 
QuestionIs anyone here? PinmemberDGamer26-Nov-10 17:59 
RantAuthor of this Script is not actively participating on this site. PinmemberDGamer20-Nov-10 14:08 
GeneralRe: Author of this Script is not actively participating on this site. PinmemberMember 1007235323-May-13 0:01 
GeneralUser ID and Password + Order details PinmemberDGamer10-Nov-10 11:09 
Generalpls send me database pls....... Pinmemberudaya kumar g s2-Nov-10 5:21 
GeneralRe: pls send me database pls....... PinmemberDGamer2-Nov-10 13:00 
GeneralRegarding Database PinmemberDGamer1-Nov-10 18:31 
Generaldatabase required urgently Pinmemberpreetibamania27-Sep-10 5:06 
GeneralRe: database required urgently [modified] PinmemberDGamer2-Nov-10 13:01 
Generaldatabase Pinmembernitinmodi20-Sep-10 9:47 
GeneralRe: database [modified] PinmemberDGamer2-Nov-10 13:01 
GeneralDatabase Pinmemberpopokatipetl4-Sep-10 23:53 
GeneralRe: Database [modified] PinmemberDGamer2-Nov-10 13:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150129.1 | Last Updated 21 Apr 2004
Article Copyright 2004 by ShruSri
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid