<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Build a Shopping Cart in ASP.NET</title>
	<atom:link href="http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/</link>
	<description>Web Development &#38; Design Tutorials</description>
	<lastBuildDate>Sat, 21 Nov 2009 22:51:56 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Kris Crosby</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-128771</link>
		<dc:creator>Kris Crosby</dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:33:31 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-128771</guid>
		<description>&#039; ViewCart.aspx.vb

Partial Class ViewCart
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        &#039; ASP.NET keeps track of the state of all server controls
        &#039; (like the GridView).  Because of this, we don&#039;t need to supply it with
        &#039; the data every time the page loads.  (No more re-checking checkboxes
        &#039; that were checked or re-selecting the right item in the drop-down when
        &#039; the page Is submitted. It&#039;s all done for you!)

        If Not IsPostBack Then
            BindData()
        End If
    End Sub

    Protected Sub BindData()
        &#039; Let&#039;s give the data to the GridView and let it work!
        &#039; The GridView will take our cart items one by one and use the properties
        &#039; that we declared as column names (DataFields)
        Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()
        gvShoppingCart.DataSource = cart.Items
        gvShoppingCart.DataBind()
    End Sub

    Protected Sub gvShoppingCart_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gvShoppingCart.RowDataBound
        &#039; If we are binding the footer row, let&#039;s add in our total
        If e.Row.RowType = DataControlRowType.Footer Then
            Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()
            e.Row.Cells(3).Text = &quot;Total: &quot; &amp; cart.GetSubTotal().ToString(&quot;C&quot;)
        End If
    End Sub

    &#039; This is the method that responds to the Remove button&#039;s click event
    Protected Sub gvShoppingCart_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles gvShoppingCart.RowCommand
        If e.CommandName = &quot;Remove&quot; Then
            Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()
            Dim productId = Convert.ToInt32(e.CommandArgument)
            cart.RemoveItem(productId)
        End If

        &#039; We now have to re-setup the data so that the GridView doesn&#039;t keep displaying the old data
        BindData()
    End Sub



End Class</description>
		<content:encoded><![CDATA[<p>&#8216; ViewCart.aspx.vb</p>
<p>Partial Class ViewCart<br />
    Inherits System.Web.UI.Page</p>
<p>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
        &#8216; ASP.NET keeps track of the state of all server controls<br />
        &#8216; (like the GridView).  Because of this, we don&#8217;t need to supply it with<br />
        &#8216; the data every time the page loads.  (No more re-checking checkboxes<br />
        &#8216; that were checked or re-selecting the right item in the drop-down when<br />
        &#8216; the page Is submitted. It&#8217;s all done for you!)</p>
<p>        If Not IsPostBack Then<br />
            BindData()<br />
        End If<br />
    End Sub</p>
<p>    Protected Sub BindData()<br />
        &#8216; Let&#8217;s give the data to the GridView and let it work!<br />
        &#8216; The GridView will take our cart items one by one and use the properties<br />
        &#8216; that we declared as column names (DataFields)<br />
        Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()<br />
        gvShoppingCart.DataSource = cart.Items<br />
        gvShoppingCart.DataBind()<br />
    End Sub</p>
<p>    Protected Sub gvShoppingCart_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gvShoppingCart.RowDataBound<br />
        &#8216; If we are binding the footer row, let&#8217;s add in our total<br />
        If e.Row.RowType = DataControlRowType.Footer Then<br />
            Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()<br />
            e.Row.Cells(3).Text = &#8220;Total: &#8221; &amp; cart.GetSubTotal().ToString(&#8221;C&#8221;)<br />
        End If<br />
    End Sub</p>
<p>    &#8216; This is the method that responds to the Remove button&#8217;s click event<br />
    Protected Sub gvShoppingCart_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles gvShoppingCart.RowCommand<br />
        If e.CommandName = &#8220;Remove&#8221; Then<br />
            Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()<br />
            Dim productId = Convert.ToInt32(e.CommandArgument)<br />
            cart.RemoveItem(productId)<br />
        End If</p>
<p>        &#8216; We now have to re-setup the data so that the GridView doesn&#8217;t keep displaying the old data<br />
        BindData()<br />
    End Sub</p>
<p>End Class</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Crosby</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-128770</link>
		<dc:creator>Kris Crosby</dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:33:11 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-128770</guid>
		<description>&#039; Default.aspx.vb
&#039; The ShoppingCart class
&#039; Holds the items that are in the cart and provides methods for their manipulation
Public Class ShoppingCart

#Region &quot;Properties&quot;

    Private _items As List(Of CartItem)
    Public Property Items() As List(Of CartItem)
        Get
            Return _items
        End Get
        Private Set(ByVal value As List(Of CartItem))
            _items = value
        End Set
    End Property

#End Region

#Region &quot;Implementation&quot;

    &#039; Readonly variables can only be set in initialization or in a constructor
    Public Shared ReadOnly Instance As ShoppingCart

    Public Shared Function GetShoppingCart() As ShoppingCart
        &#039; If the cart is not in the session, create one and put it there
        If HttpContext.Current.Session(&quot;ASPNETShoppingCart&quot;) Is Nothing Then
            Dim cart As New ShoppingCart()
            cart.Items = New List(Of CartItem)()
            HttpContext.Current.Session(&quot;ASPNETShoppingCart&quot;) = cart
        End If

        Return (DirectCast(HttpContext.Current.Session(&quot;ASPNETShoppingCart&quot;), ShoppingCart))

    End Function


#End Region

#Region &quot;Item Modification Methods&quot;

    &#039; AddItem() - Adds an item to the shopping
    Public Sub AddItem(ByVal productId As Integer)
        &#039; Create a new item to add to the cart
        Dim newItem = New CartItem(productId)

        &#039; If this item already exists in our list of items, increase the quantity
        &#039; Otherwise, add the new item to the list
        If Items.Contains(newItem) Then
            For Each item As CartItem In Items
                If item.Equals(newItem) Then
                    item.Quantity += 1
                    Return
                End If
            Next
        Else
            newItem.Quantity = 1
            Items.Add(newItem)
        End If

    End Sub

    &#039; SetItemQuantity() - Changes the quantity of an item in the cart
    Public Sub SetItemQuantity(ByVal productId As Integer, ByVal quantity As Integer)
        &#039; If we are setting the quantity to 0, remove the item entirely
        If quantity = 0 Then
            RemoveItem(productId)
            Return
        End If

        &#039; Find the item and update the quantity
        Dim updatedItem = New CartItem(productId)
        For Each item As CartItem In Items
            If item.Equals(updatedItem) Then
                item.Quantity = quantity
                Return
            End If
        Next
    End Sub

    &#039; RemoveItem() - Removes an item from the shopping cart
    Public Sub RemoveItem(ByVal productId As Integer)
        Dim removedItem = New CartItem(productId)

        For Each item As CartItem In Items
            If item.Equals(removedItem) Then
                Items.Remove(item)
                Return
            End If
        Next
    End Sub

#End Region

#Region &quot;Reporting Methods&quot;

    &#039; GetSubTotal() - returns the total price of all of the items before tax, shipping, etc.
    Public Function GetSubTotal() As Decimal
        Dim subTotal As Decimal = 0
        For Each item As CartItem In Items
            subTotal += item.TotalPrice
        Next

        Return subTotal
    End Function

#End Region

End Class

Partial Class _Default
    Inherits System.Web.UI.Page

	Protected Sub btnAddShoes_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddShirt.Click
        &#039; Add product 1 to the shopping cart
        Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()
        cart.AddItem(1)

		&#039; Redirect the user to view their shopping cart
		Response.Redirect(&quot;ViewCart.aspx&quot;)
	End Sub

    Protected Sub btnAddShirt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddShorts.Click
        Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()
        cart.AddItem(2)
        Response.Redirect(&quot;ViewCart.aspx&quot;)
    End Sub

    Protected Sub btnAddPants_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddShoes.Click
        Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()
        cart.AddItem(3)
        Response.Redirect(&quot;ViewCart.aspx&quot;)
    End Sub
End Class</description>
		<content:encoded><![CDATA[<p>&#8216; Default.aspx.vb<br />
&#8216; The ShoppingCart class<br />
&#8216; Holds the items that are in the cart and provides methods for their manipulation<br />
Public Class ShoppingCart</p>
<p>#Region &#8220;Properties&#8221;</p>
<p>    Private _items As List(Of CartItem)<br />
    Public Property Items() As List(Of CartItem)<br />
        Get<br />
            Return _items<br />
        End Get<br />
        Private Set(ByVal value As List(Of CartItem))<br />
            _items = value<br />
        End Set<br />
    End Property</p>
<p>#End Region</p>
<p>#Region &#8220;Implementation&#8221;</p>
<p>    &#8216; Readonly variables can only be set in initialization or in a constructor<br />
    Public Shared ReadOnly Instance As ShoppingCart</p>
<p>    Public Shared Function GetShoppingCart() As ShoppingCart<br />
        &#8216; If the cart is not in the session, create one and put it there<br />
        If HttpContext.Current.Session(&#8221;ASPNETShoppingCart&#8221;) Is Nothing Then<br />
            Dim cart As New ShoppingCart()<br />
            cart.Items = New List(Of CartItem)()<br />
            HttpContext.Current.Session(&#8221;ASPNETShoppingCart&#8221;) = cart<br />
        End If</p>
<p>        Return (DirectCast(HttpContext.Current.Session(&#8221;ASPNETShoppingCart&#8221;), ShoppingCart))</p>
<p>    End Function</p>
<p>#End Region</p>
<p>#Region &#8220;Item Modification Methods&#8221;</p>
<p>    &#8216; AddItem() &#8211; Adds an item to the shopping<br />
    Public Sub AddItem(ByVal productId As Integer)<br />
        &#8216; Create a new item to add to the cart<br />
        Dim newItem = New CartItem(productId)</p>
<p>        &#8216; If this item already exists in our list of items, increase the quantity<br />
        &#8216; Otherwise, add the new item to the list<br />
        If Items.Contains(newItem) Then<br />
            For Each item As CartItem In Items<br />
                If item.Equals(newItem) Then<br />
                    item.Quantity += 1<br />
                    Return<br />
                End If<br />
            Next<br />
        Else<br />
            newItem.Quantity = 1<br />
            Items.Add(newItem)<br />
        End If</p>
<p>    End Sub</p>
<p>    &#8216; SetItemQuantity() &#8211; Changes the quantity of an item in the cart<br />
    Public Sub SetItemQuantity(ByVal productId As Integer, ByVal quantity As Integer)<br />
        &#8216; If we are setting the quantity to 0, remove the item entirely<br />
        If quantity = 0 Then<br />
            RemoveItem(productId)<br />
            Return<br />
        End If</p>
<p>        &#8216; Find the item and update the quantity<br />
        Dim updatedItem = New CartItem(productId)<br />
        For Each item As CartItem In Items<br />
            If item.Equals(updatedItem) Then<br />
                item.Quantity = quantity<br />
                Return<br />
            End If<br />
        Next<br />
    End Sub</p>
<p>    &#8216; RemoveItem() &#8211; Removes an item from the shopping cart<br />
    Public Sub RemoveItem(ByVal productId As Integer)<br />
        Dim removedItem = New CartItem(productId)</p>
<p>        For Each item As CartItem In Items<br />
            If item.Equals(removedItem) Then<br />
                Items.Remove(item)<br />
                Return<br />
            End If<br />
        Next<br />
    End Sub</p>
<p>#End Region</p>
<p>#Region &#8220;Reporting Methods&#8221;</p>
<p>    &#8216; GetSubTotal() &#8211; returns the total price of all of the items before tax, shipping, etc.<br />
    Public Function GetSubTotal() As Decimal<br />
        Dim subTotal As Decimal = 0<br />
        For Each item As CartItem In Items<br />
            subTotal += item.TotalPrice<br />
        Next</p>
<p>        Return subTotal<br />
    End Function</p>
<p>#End Region</p>
<p>End Class</p>
<p>Partial Class _Default<br />
    Inherits System.Web.UI.Page</p>
<p>	Protected Sub btnAddShoes_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddShirt.Click<br />
        &#8216; Add product 1 to the shopping cart<br />
        Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()<br />
        cart.AddItem(1)</p>
<p>		&#8216; Redirect the user to view their shopping cart<br />
		Response.Redirect(&#8221;ViewCart.aspx&#8221;)<br />
	End Sub</p>
<p>    Protected Sub btnAddShirt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddShorts.Click<br />
        Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()<br />
        cart.AddItem(2)<br />
        Response.Redirect(&#8221;ViewCart.aspx&#8221;)<br />
    End Sub</p>
<p>    Protected Sub btnAddPants_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddShoes.Click<br />
        Dim cart As ShoppingCart = ShoppingCart.GetShoppingCart()<br />
        cart.AddItem(3)<br />
        Response.Redirect(&#8221;ViewCart.aspx&#8221;)<br />
    End Sub<br />
End Class</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Crosby</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-128769</link>
		<dc:creator>Kris Crosby</dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:32:48 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-128769</guid>
		<description>&#039; ShoppingCart.vb
Imports Microsoft.VisualBasic

&#039; The ShoppingCart class
&#039; Holds the items that are in the cart and provides methods for their manipulation
Public Class ShoppingCart

#Region &quot;Properties&quot;

	Private _items As List(Of CartItem)
	Public Property Items() As List(Of CartItem)
		Get
			Return _items
		End Get
		Private Set(ByVal value As List(Of CartItem))
			_items = value
		End Set
	End Property

#End Region

#Region &quot;Implementation&quot;

    &#039; Readonly variables can only be set in initialization or in a constructor
    Public Shared ReadOnly Instance As ShoppingCart

    Public Shared Function GetShoppingCart() As ShoppingCart
        &#039; If the cart is not in the session, create one and put it there
        If HttpContext.Current.Session(&quot;ASPNETShoppingCart&quot;) Is Nothing Then
            Dim cart As New ShoppingCart()
            cart.Items = New List(Of CartItem)()
            HttpContext.Current.Session(&quot;ASPNETShoppingCart&quot;) = cart
        End If

        Return (DirectCast(HttpContext.Current.Session(&quot;ASPNETShoppingCart&quot;), ShoppingCart))

    End Function


#End Region

#Region &quot;Item Modification Methods&quot;

    &#039; AddItem() - Adds an item to the shopping
    Public Sub AddItem(ByVal productId As Integer)
        &#039; Create a new item to add to the cart
        Dim newItem = New CartItem(productId)

        &#039; If this item already exists in our list of items, increase the quantity
        &#039; Otherwise, add the new item to the list
        If Items.Contains(newItem) Then
            For Each item As CartItem In Items
                If item.Equals(newItem) Then
                    item.Quantity += 1
                    Return
                End If
            Next
        Else
            newItem.Quantity = 1
            Items.Add(newItem)
        End If

    End Sub

    &#039; SetItemQuantity() - Changes the quantity of an item in the cart
    Public Sub SetItemQuantity(ByVal productId As Integer, ByVal quantity As Integer)
        &#039; If we are setting the quantity to 0, remove the item entirely
        If quantity = 0 Then
            RemoveItem(productId)
            Return
        End If

        &#039; Find the item and update the quantity
        Dim updatedItem = New CartItem(productId)
        For Each item As CartItem In Items
            If item.Equals(updatedItem) Then
                item.Quantity = quantity
                Return
            End If
        Next
    End Sub

    &#039; RemoveItem() - Removes an item from the shopping cart
    Public Sub RemoveItem(ByVal productId As Integer)
        Dim removedItem = New CartItem(productId)

        For Each item As CartItem In Items
            If item.Equals(removedItem) Then
                Items.Remove(item)
                Return
            End If
        Next
    End Sub

#End Region

#Region &quot;Reporting Methods&quot;

    &#039; GetSubTotal() - returns the total price of all of the items before tax, shipping, etc.
    Public Function GetSubTotal() As Decimal
        Dim subTotal As Decimal = 0
        For Each item As CartItem In Items
            subTotal += item.TotalPrice
        Next

        Return subTotal
    End Function

#End Region

End Class</description>
		<content:encoded><![CDATA[<p>&#8216; ShoppingCart.vb<br />
Imports Microsoft.VisualBasic</p>
<p>&#8216; The ShoppingCart class<br />
&#8216; Holds the items that are in the cart and provides methods for their manipulation<br />
Public Class ShoppingCart</p>
<p>#Region &#8220;Properties&#8221;</p>
<p>	Private _items As List(Of CartItem)<br />
	Public Property Items() As List(Of CartItem)<br />
		Get<br />
			Return _items<br />
		End Get<br />
		Private Set(ByVal value As List(Of CartItem))<br />
			_items = value<br />
		End Set<br />
	End Property</p>
<p>#End Region</p>
<p>#Region &#8220;Implementation&#8221;</p>
<p>    &#8216; Readonly variables can only be set in initialization or in a constructor<br />
    Public Shared ReadOnly Instance As ShoppingCart</p>
<p>    Public Shared Function GetShoppingCart() As ShoppingCart<br />
        &#8216; If the cart is not in the session, create one and put it there<br />
        If HttpContext.Current.Session(&#8221;ASPNETShoppingCart&#8221;) Is Nothing Then<br />
            Dim cart As New ShoppingCart()<br />
            cart.Items = New List(Of CartItem)()<br />
            HttpContext.Current.Session(&#8221;ASPNETShoppingCart&#8221;) = cart<br />
        End If</p>
<p>        Return (DirectCast(HttpContext.Current.Session(&#8221;ASPNETShoppingCart&#8221;), ShoppingCart))</p>
<p>    End Function</p>
<p>#End Region</p>
<p>#Region &#8220;Item Modification Methods&#8221;</p>
<p>    &#8216; AddItem() &#8211; Adds an item to the shopping<br />
    Public Sub AddItem(ByVal productId As Integer)<br />
        &#8216; Create a new item to add to the cart<br />
        Dim newItem = New CartItem(productId)</p>
<p>        &#8216; If this item already exists in our list of items, increase the quantity<br />
        &#8216; Otherwise, add the new item to the list<br />
        If Items.Contains(newItem) Then<br />
            For Each item As CartItem In Items<br />
                If item.Equals(newItem) Then<br />
                    item.Quantity += 1<br />
                    Return<br />
                End If<br />
            Next<br />
        Else<br />
            newItem.Quantity = 1<br />
            Items.Add(newItem)<br />
        End If</p>
<p>    End Sub</p>
<p>    &#8216; SetItemQuantity() &#8211; Changes the quantity of an item in the cart<br />
    Public Sub SetItemQuantity(ByVal productId As Integer, ByVal quantity As Integer)<br />
        &#8216; If we are setting the quantity to 0, remove the item entirely<br />
        If quantity = 0 Then<br />
            RemoveItem(productId)<br />
            Return<br />
        End If</p>
<p>        &#8216; Find the item and update the quantity<br />
        Dim updatedItem = New CartItem(productId)<br />
        For Each item As CartItem In Items<br />
            If item.Equals(updatedItem) Then<br />
                item.Quantity = quantity<br />
                Return<br />
            End If<br />
        Next<br />
    End Sub</p>
<p>    &#8216; RemoveItem() &#8211; Removes an item from the shopping cart<br />
    Public Sub RemoveItem(ByVal productId As Integer)<br />
        Dim removedItem = New CartItem(productId)</p>
<p>        For Each item As CartItem In Items<br />
            If item.Equals(removedItem) Then<br />
                Items.Remove(item)<br />
                Return<br />
            End If<br />
        Next<br />
    End Sub</p>
<p>#End Region</p>
<p>#Region &#8220;Reporting Methods&#8221;</p>
<p>    &#8216; GetSubTotal() &#8211; returns the total price of all of the items before tax, shipping, etc.<br />
    Public Function GetSubTotal() As Decimal<br />
        Dim subTotal As Decimal = 0<br />
        For Each item As CartItem In Items<br />
            subTotal += item.TotalPrice<br />
        Next</p>
<p>        Return subTotal<br />
    End Function</p>
<p>#End Region</p>
<p>End Class</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Crosby</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-128768</link>
		<dc:creator>Kris Crosby</dc:creator>
		<pubDate>Mon, 09 Nov 2009 19:32:24 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-128768</guid>
		<description>For VB, I used a C#-&gt;VB converter for the changed code for the same 3 files (ShoppingCart.vb,Default.aspx.vb and ViewCart.aspx.vb) Someone should really update the example files. A shopping cart for one person doesn&#039;t make any sense and dispite the good intention of the author, if your going to teach something which establishes yourself as an expert, teach it right, and fix your mistakes acurately if they are discovered later. I am no programmer and I have to fix this code for all you programmers out there.</description>
		<content:encoded><![CDATA[<p>For VB, I used a C#-&gt;VB converter for the changed code for the same 3 files (ShoppingCart.vb,Default.aspx.vb and ViewCart.aspx.vb) Someone should really update the example files. A shopping cart for one person doesn&#8217;t make any sense and dispite the good intention of the author, if your going to teach something which establishes yourself as an expert, teach it right, and fix your mistakes acurately if they are discovered later. I am no programmer and I have to fix this code for all you programmers out there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Crosby</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-128765</link>
		<dc:creator>Kris Crosby</dc:creator>
		<pubDate>Mon, 09 Nov 2009 18:57:49 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-128765</guid>
		<description>//Default.aspx.cs

using System;

public partial class _Default : System.Web.UI.Page {
	protected void Page_Load(object sender, EventArgs e) {

	}

	protected void btnAddShoes_Click(object sender, EventArgs e) {
		// Add product 1 to the shopping cart
        ShoppingCart cart = ShoppingCart.GetShoppingCart();
        cart.AddItem(1);
		// Redirect the user to view their shopping cart
		Response.Redirect(&quot;ViewCart.aspx&quot;);
	}

	protected void btnAddShirt_Click(object sender, EventArgs e) {
        ShoppingCart cart = ShoppingCart.GetShoppingCart();
        cart.AddItem(2);
		Response.Redirect(&quot;ViewCart.aspx&quot;);
	}

	protected void btnAddPants_Click(object sender, EventArgs e) {
        ShoppingCart cart = ShoppingCart.GetShoppingCart();
        cart.AddItem(3);
		Response.Redirect(&quot;ViewCart.aspx&quot;);
	}

}</description>
		<content:encoded><![CDATA[<p>//Default.aspx.cs</p>
<p>using System;</p>
<p>public partial class _Default : System.Web.UI.Page {<br />
	protected void Page_Load(object sender, EventArgs e) {</p>
<p>	}</p>
<p>	protected void btnAddShoes_Click(object sender, EventArgs e) {<br />
		// Add product 1 to the shopping cart<br />
        ShoppingCart cart = ShoppingCart.GetShoppingCart();<br />
        cart.AddItem(1);<br />
		// Redirect the user to view their shopping cart<br />
		Response.Redirect(&#8221;ViewCart.aspx&#8221;);<br />
	}</p>
<p>	protected void btnAddShirt_Click(object sender, EventArgs e) {<br />
        ShoppingCart cart = ShoppingCart.GetShoppingCart();<br />
        cart.AddItem(2);<br />
		Response.Redirect(&#8221;ViewCart.aspx&#8221;);<br />
	}</p>
<p>	protected void btnAddPants_Click(object sender, EventArgs e) {<br />
        ShoppingCart cart = ShoppingCart.GetShoppingCart();<br />
        cart.AddItem(3);<br />
		Response.Redirect(&#8221;ViewCart.aspx&#8221;);<br />
	}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Crosby</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-128764</link>
		<dc:creator>Kris Crosby</dc:creator>
		<pubDate>Mon, 09 Nov 2009 18:56:27 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-128764</guid>
		<description>//ViewCart.aspx.cs

using System;
using System.Web.UI.WebControls;
/*************************** MEASURE LINE *****************************************/
public partial class ViewCart : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
		// ASP.NET keeps track of the state of all server controls
		// (like the GridView).  Because of this, we don&#039;t need to supply it with
		// the data every time the page loads.  (No more re-checking checkboxes
		// that were checked or re-selecting the right item in the drop-down when
		// the page is submitted.  It&#039;s all done for you!)
		if (!IsPostBack)
			BindData();
    }


    protected void BindData()
    {
        // Let’s give the data to the GridView and let it work!
        // The GridView will take our cart items one by one and use the properties
        // that we declared as column names (DataFields)
        ShoppingCart cart = ShoppingCart.GetShoppingCart();
        gvShoppingCart.DataSource = cart.Items;
        gvShoppingCart.DataBind();
    }


	protected void gvShoppingCart_RowDataBound(object sender, GridViewRowEventArgs e) {
		// If we are binding the footer row, let&#039;s add in our total
        
        if (e.Row.RowType == DataControlRowType.Footer) {
            ShoppingCart cart = ShoppingCart.GetShoppingCart();
            e.Row.Cells[3].Text = &quot;Total: &quot; + cart.GetSubTotal().ToString(&quot;C&quot;);       
        }
	}

	/**
	 * This is the method that responds to the Remove button&#039;s click event
	 */
	protected void gvShoppingCart_RowCommand(object sender, GridViewCommandEventArgs e) {
		if (e.CommandName == &quot;Remove&quot;) {
			int productId = Convert.ToInt32(e.CommandArgument);
            ShoppingCart cart = ShoppingCart.GetShoppingCart();
            cart.RemoveItem(productId);
        }

		// We now have to re-setup the data so that the GridView doesn&#039;t keep
		// displaying the old data
		BindData();
	}

	protected void btnUpdateCart_Click(object sender, EventArgs e) {
		foreach (GridViewRow row in gvShoppingCart.Rows) {
			if (row.RowType == DataControlRowType.DataRow) {
				// We&#039;ll use a try catch block in case something other than a number is typed in
				// If so, we&#039;ll just ignore it.
				try {
					// Get the productId from the GridView&#039;s datakeys
					int productId = Convert.ToInt32(gvShoppingCart.DataKeys[row.RowIndex].Value);
					// Find the quantity TextBox and retrieve the value
					int quantity = int.Parse(((TextBox)row.Cells[1].FindControl(&quot;txtQuantity&quot;)).Text);
                    ShoppingCart cart = ShoppingCart.GetShoppingCart();
                    cart.SetItemQuantity(productId, quantity);
                } catch (FormatException) { }
			}
		}

		BindData();
	}
}</description>
		<content:encoded><![CDATA[<p>//ViewCart.aspx.cs</p>
<p>using System;<br />
using System.Web.UI.WebControls;<br />
/*************************** MEASURE LINE *****************************************/<br />
public partial class ViewCart : System.Web.UI.Page<br />
{<br />
    protected void Page_Load(object sender, EventArgs e)<br />
    {<br />
		// ASP.NET keeps track of the state of all server controls<br />
		// (like the GridView).  Because of this, we don&#8217;t need to supply it with<br />
		// the data every time the page loads.  (No more re-checking checkboxes<br />
		// that were checked or re-selecting the right item in the drop-down when<br />
		// the page is submitted.  It&#8217;s all done for you!)<br />
		if (!IsPostBack)<br />
			BindData();<br />
    }</p>
<p>    protected void BindData()<br />
    {<br />
        // Let’s give the data to the GridView and let it work!<br />
        // The GridView will take our cart items one by one and use the properties<br />
        // that we declared as column names (DataFields)<br />
        ShoppingCart cart = ShoppingCart.GetShoppingCart();<br />
        gvShoppingCart.DataSource = cart.Items;<br />
        gvShoppingCart.DataBind();<br />
    }</p>
<p>	protected void gvShoppingCart_RowDataBound(object sender, GridViewRowEventArgs e) {<br />
		// If we are binding the footer row, let&#8217;s add in our total</p>
<p>        if (e.Row.RowType == DataControlRowType.Footer) {<br />
            ShoppingCart cart = ShoppingCart.GetShoppingCart();<br />
            e.Row.Cells[3].Text = &#8220;Total: &#8221; + cart.GetSubTotal().ToString(&#8221;C&#8221;);<br />
        }<br />
	}</p>
<p>	/**<br />
	 * This is the method that responds to the Remove button&#8217;s click event<br />
	 */<br />
	protected void gvShoppingCart_RowCommand(object sender, GridViewCommandEventArgs e) {<br />
		if (e.CommandName == &#8220;Remove&#8221;) {<br />
			int productId = Convert.ToInt32(e.CommandArgument);<br />
            ShoppingCart cart = ShoppingCart.GetShoppingCart();<br />
            cart.RemoveItem(productId);<br />
        }</p>
<p>		// We now have to re-setup the data so that the GridView doesn&#8217;t keep<br />
		// displaying the old data<br />
		BindData();<br />
	}</p>
<p>	protected void btnUpdateCart_Click(object sender, EventArgs e) {<br />
		foreach (GridViewRow row in gvShoppingCart.Rows) {<br />
			if (row.RowType == DataControlRowType.DataRow) {<br />
				// We&#8217;ll use a try catch block in case something other than a number is typed in<br />
				// If so, we&#8217;ll just ignore it.<br />
				try {<br />
					// Get the productId from the GridView&#8217;s datakeys<br />
					int productId = Convert.ToInt32(gvShoppingCart.DataKeys[row.RowIndex].Value);<br />
					// Find the quantity TextBox and retrieve the value<br />
					int quantity = int.Parse(((TextBox)row.Cells[1].FindControl(&#8221;txtQuantity&#8221;)).Text);<br />
                    ShoppingCart cart = ShoppingCart.GetShoppingCart();<br />
                    cart.SetItemQuantity(productId, quantity);<br />
                } catch (FormatException) { }<br />
			}<br />
		}</p>
<p>		BindData();<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Crosby</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-128762</link>
		<dc:creator>Kris Crosby</dc:creator>
		<pubDate>Mon, 09 Nov 2009 18:54:05 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-128762</guid>
		<description>To make this work with multiple users here is the complete solution to make this work for all of us who are not programmers. First in C. You need the change the following files from the example: ShoppingCart.cs per comments above. Then Default.aspx.cs per comments above. and last ViewCart.aspx.cs anytime the instance was called.</description>
		<content:encoded><![CDATA[<p>To make this work with multiple users here is the complete solution to make this work for all of us who are not programmers. First in C. You need the change the following files from the example: ShoppingCart.cs per comments above. Then Default.aspx.cs per comments above. and last ViewCart.aspx.cs anytime the instance was called.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-117485</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Sun, 11 Oct 2009 17:44:36 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-117485</guid>
		<description>I dont really use ASP that much, but still pretty cool. :P</description>
		<content:encoded><![CDATA[<p>I dont really use ASP that much, but still pretty cool. <img src='http://net.tutsplus.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Velibor</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-102505</link>
		<dc:creator>Velibor</dc:creator>
		<pubDate>Sat, 05 Sep 2009 15:25:52 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-102505</guid>
		<description>Works fine. That&#039;s what I looking for. Maybe some AJAX in this could improve interaction without separately web page for viewing cart. Shopping cart could be visible from some pop-up window etc. :D 

Thanks for great tut.</description>
		<content:encoded><![CDATA[<p>Works fine. That&#8217;s what I looking for. Maybe some AJAX in this could improve interaction without separately web page for viewing cart. Shopping cart could be visible from some pop-up window etc. <img src='http://net.tutsplus.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  </p>
<p>Thanks for great tut.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/#comment-93688</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Wed, 19 Aug 2009 13:43:36 +0000</pubDate>
		<guid isPermaLink="false">http://nettuts.com/?p=1663#comment-93688</guid>
		<description>Hello Don 

Thanks , is really good

I need to show a produt list with : Id, Name, Price, Graph, and description , do you have some samples ?

Regards</description>
		<content:encoded><![CDATA[<p>Hello Don </p>
<p>Thanks , is really good</p>
<p>I need to show a produt list with : Id, Name, Price, Graph, and description , do you have some samples ?</p>
<p>Regards</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!--
This site's performance optimized by W3 Total Cache:

W3 Total Cache improves the user experience of your blog by caching
frequent operations, reducing the weight of various files and providing
transparent content delivery network integration.

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 1/7 queries in 0.006 seconds using memcached
Content Delivery Network via 

Served from: psdtutsplus.com @ 2009-11-21 15:49:42 -->