Few of my friends were asking me about the creation of Web cart and use of footer template in GridView. I remember the days of asp 3.0 when we use to make web cart and it use to take many days.
I have taken a GridView, Dropdown box and a Button. The name of my page is default.aspx and default.cs. This is just concept. It is not full Web Cart. You can just use the concept and implement it according to your need. I have also highlighted the need of footer template.
Copy the following code in ASPX Page.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Web Cart </title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td style="width: 100px">
<asp:DropDownList ID="DropDownList1" runat="server" Width="198px">
<asp:ListItem Value="25.50">LUX</asp:ListItem>
<asp:ListItem Value="45.60">MEDIMAX</asp:ListItem>
<asp:ListItem Value="34.75">CIBACA</asp:ListItem>
<asp:ListItem Value="43.50">CLOSEUP</asp:ListItem>
</asp:DropDownList></td>
<td style="width: 100px">
<asp:Button ID="btnAdd" runat="server" Text="Add to Cart" OnClick="btnAdd_Click" /></td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="GridView1"
ShowFooter="true" DataKeyNames="ProductId"
AutoGenerateColumns="false" runat="server">
<Columns>
<asp:BoundField DataField="Productid" HeaderText="Product Id" />
<asp:BoundField DataField="ProductName" FooterText="Total" HeaderText="Product Name" />
<asp:TemplateField HeaderText="Unit Price" FooterStyle-Font-Bold="True">
<ItemTemplate>
<%# GetUnitPrice(decimal.Parse(Eval("UnitPrice").ToString())).ToString("N2") %>
</ItemTemplate>
<FooterTemplate>
<%# GetTotal().ToString("N2") %>

dabbu kumarPosted Dec 14, 2015, 9:07 AM
Sir, how to remove row from gridview??
Umesh KumarPosted Jun 8, 2013, 12:53 PM
Thank U very much All doubts are all Clear
Amit chirutkarPosted Sep 6, 2010, 3:11 AM
how can i insert my data list control data in grid view
Ziggy RafiqPosted May 21, 2010, 9:34 PM
how will you update your cart qty i.e 10 qty