创建一个购物篮 [英] Creating a shopping basket

查看:79
本文介绍了创建一个购物篮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<pre lang="vb">

如何使用asp.net 2010 vb创建购物篮。我创建了一个产品的网格视图,点击添加到购物篮按钮没有将结果带到购物篮。



SHOUTING已删除 - OriginalGriff [ / edit]



这就是我所拥有的。什么是前进的方向?



<%@ Page Title =Language =VBMasterPageFile =〜/ MasterPage.masterAutoEventWireup =falseCodeFile =Advertise.aspx.vbInherits =Advertise%>

< asp:Content ID =Content1ContentPlaceHolderID =headRunat =Server>

< style type =text / css>

.style14

{

宽度:150px;

}

.style15

{

宽度:150px;

身高:26px; < br $>
}

.style16

{

身高:26px;

}

.style17

{

font-size:large;

}

< / style>



< asp:Content ID =Content2ContentPlaceHolderID =ContentPlaceHolder1Runat =Server>

How do I create a shopping basket using asp.net 2010 vb. I have created a grid view of products and a click to the add to basket button is not bringing the results to the basket.

[edit]SHOUTING removed - OriginalGriff[/edit]

This is what I have. Whats the way forward?

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Advertise.aspx.vb" Inherits="Advertise" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style14
{
width: 150px;
}
.style15
{
width: 150px;
height: 26px;
}
.style16
{
height: 26px;
}
.style17
{
font-size: large;
}
</style>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">



< asp:Mul tiView ID =MultiView1runat =serverActiveViewIndex =0>

< asp:View ID =View1runat =serverViewStateMode =Enabled>



产品名称 < asp:TextBox ID =TextBoxProductNamerunat =server>

     
< asp:Button ID =ButtonSearchrunat =serverText =Search/>

  ;  




 

< asp:GridView ID =GridView1runat =serverAutoGenerateColumns =False

CellPadding =4DataKeyNames =ProductIDDataSourceID =SqlDataSource1

ForeColor =#333333GridLines =无>

< alternatingrowstyle backcolor =White>

< colum NS> < asp:BoundField DataField =ProductIDHeaderText =ProductID

InsertVisible =FalseReadOnly =TrueSortExpression =ProductID/>

< ; asp:BoundField DataField =ProductNameHeaderText =ProductName

SortExpression =ProductName/>

< asp:BoundField DataField =DecsriptionHeaderText = Decsription

SortExpression =Decsription/>

< asp:BoundField DataField =CategoryHeaderText =Category

SortExpression =Category/>

< asp:BoundField DataField =PriceHeaderText =PriceSortExpression =Price/>

< asp :ButtonField CommandName =AddToBasket文字=添加到购物篮/>

< editrowstyle backcolor =#2461BF>

< footerstyle backcolor =#507CD1font-bold = Trueforecolor =White>

< HeaderStyle BackColor =#507CD1Font-Bold =TrueForeColor =White/>

< pagerstyle backcolor =#2461BFforecolor =Whitehorizo​​ntalalign =Center>

< rowstyle backcolor =#EFF3FB>

< SelectedRowStyle BackColor =#D1DDF1Font-Bold =TrueForeColor =#333333

BorderStyle =Solid/>

< sortedascendingcellstyle backcolor = #F5F7FB>

< sortedascendingheaderstyle backcolor =#6D95E1>

< sorteddescendingcellstyle backcolor =#E9EBEF>

< sorteddescendingheaderstyle backcolor =#4870BE>



< asp: SqlDataSource ID =SqlDataSource1runat =server

ConnectionString =<%$ ConnectionStrings:DatabaseConnectionString1%>

SelectCommand =SELECT DISTINCT * FROM [Product] WHERE([ProductName] LIKE''%''+ @ProductName +''%'')>

< SelectParameters>

< asp:ControlParameter ControlID =TextBoxProductNameName =ProductName

PropertyName =TextType =String/>

< / SelectParameters>









< asp:View ID =ViewBasketrunat =serverViewStateMode =Enabled>

购物篮< asp:GridView ID =GridViewBasket

runat =serverAutoGenerateColumns =FalseAutoGenerateDeleteButton =True

AutoGenerateEditButton =Tru eCellPadding =4ClientIDMode =AutoID

DataKeyNames =ProductIDForeColor =#333333

GridLines =Horizo​​ntalEnablePersistedSelection =TruePageIndex =1>

< alternatingrowstyle backcolor =White>

< columns> < asp:BoundField DataField =ProductIDHeaderText =ProductIDReadOnly =True

SortExpression =ProductID/>

< asp:BoundField DataField =ProductNameHeaderText =ProductName

ReadOnly =TrueSortExpression =ProductName/>

< asp:TemplateField HeaderText =Quantity>

< itemtemplate>

< asp:TextBox ID =TextBoxQuantityrunat =server>

< asp:LinkBut​​ton ID =删除runat =serverCommandName =删除>删除





< asp:BoundField DataField =价格DataFormatString ={0:c}HeaderText =价格

ReadOnly =True/>

< asp:BoundF ield DataField =TotalCostDataFormatString ={0:c}

HeaderText =总费用/>

< editrowstyle backcolor =#2461BF> ;

< footerstyle backcolor =#507CD1font-bold =Trueforecolor =White>

< HeaderStyle BackColor =#507CD1字体-Bold =TrueForeColor =白色/>

< pagerstyle backcolor =#2461BFforecolor =白色horizo​​ntalalign =中心>

< rowstyle backcolor =#EFF3FB>

< SelectedRowStyle BackColor =#D1DDF1Font-Bold =TrueForeColor =#333333/>

< sortedascendingcellstyle backcolor =#F5F7FB>

< sortedascendingheaderstyle backcolor =#6D95E1>

< sorteddescendingcellstyle backcolor =#E9EBEF >

&l t; sorteddescendingheaderstyle backcolor =#4870BE>






总价格< asp:标签ID =Label1runat =serverText =Label>



< asp:查看ID =View3runat =server>



< asp:查看ID =View4runat =server>



< asp:查看ID = View5runat =server>



< asp:查看ID =View6runat =server>






<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server" ViewStateMode="Enabled">

Product Name <asp:TextBox ID="TextBoxProductName" runat="server">
     
<asp:Button ID="ButtonSearch" runat="server" Text="Search" />
   


 
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None">
<alternatingrowstyle backcolor="White">
<columns> <asp:BoundField DataField="ProductID" HeaderText="ProductID"
InsertVisible="False" ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName"
SortExpression="ProductName" />
<asp:BoundField DataField="Decsription" HeaderText="Decsription"
SortExpression="Decsription" />
<asp:BoundField DataField="Category" HeaderText="Category"
SortExpression="Category" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:ButtonField CommandName="AddToBasket" Text="Add To Basket" />
<editrowstyle backcolor="#2461BF">
<footerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center">
<rowstyle backcolor="#EFF3FB">
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333"
BorderStyle="Solid" />
<sortedascendingcellstyle backcolor="#F5F7FB">
<sortedascendingheaderstyle backcolor="#6D95E1">
<sorteddescendingcellstyle backcolor="#E9EBEF">
<sorteddescendingheaderstyle backcolor="#4870BE">

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString1 %>"
SelectCommand="SELECT DISTINCT * FROM [Product] WHERE ([ProductName] LIKE ''%'' + @ProductName + ''%'')">
<SelectParameters>
<asp:ControlParameter ControlID="TextBoxProductName" Name="ProductName"
PropertyName="Text" Type="String" />
</SelectParameters>




<asp:View ID="ViewBasket" runat="server" ViewStateMode="Enabled">
Basket<asp:GridView ID="GridViewBasket"
runat="server" AutoGenerateColumns="False" AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True" CellPadding="4" ClientIDMode="AutoID"
DataKeyNames="ProductID" ForeColor="#333333"
GridLines="Horizontal" EnablePersistedSelection="True" PageIndex="1">
<alternatingrowstyle backcolor="White">
<columns> <asp:BoundField DataField="ProductID" HeaderText="ProductID" ReadOnly="True"
SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName"
ReadOnly="True" SortExpression="ProductName" />
<asp:TemplateField HeaderText="Quantity">
<itemtemplate>
<asp:TextBox ID="TextBoxQuantity" runat="server">
<asp:LinkButton ID="Remove" runat="server" CommandName="Remove">Remove


<asp:BoundField DataField="Price" DataFormatString="{0:c}" HeaderText="Price"
ReadOnly="True" />
<asp:BoundField DataField="TotalCost" DataFormatString="{0:c}"
HeaderText="Total Cost" />
<editrowstyle backcolor="#2461BF">
<footerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center">
<rowstyle backcolor="#EFF3FB">
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<sortedascendingcellstyle backcolor="#F5F7FB">
<sortedascendingheaderstyle backcolor="#6D95E1">
<sorteddescendingcellstyle backcolor="#E9EBEF">
<sorteddescendingheaderstyle backcolor="#4870BE">



Total Price<asp:Label ID="Label1" runat="server" Text="Label">

<asp:View ID="View3" runat="server">

<asp:View ID="View4" runat="server">

<asp:View ID="View5" runat="server">

<asp:View ID="View6" runat="server">




 


 

推荐答案

ConnectionStrings:DatabaseConnectionString1%>

SelectCommand =SELECT DISTINCT * FROM [Product] WHERE([ProductName] LIKE''%''+ @ProductName +''%'')>

< SelectParame ters>

< asp:ControlParameter ControlID =TextBoxProductNameName =ProductName

PropertyName =TextType =String/>

< / SelectParameters>









< ; asp:View ID =ViewBasketrunat =serverViewStateMode =Enabled>

购物篮< asp:GridView ID = GridViewBasket

runat =serverAutoGenerateColumns =FalseAutoGenerateDeleteButton =True

AutoGenerateEditButton =TrueCellPadding =4ClientIDMode =AutoID

DataKeyNames =ProductIDForeColor =#333333

GridLines =Horizo​​ntalEnablePersistedSelection =TruePageIndex =1>

< alternatingrowstyle backcolor =White>

< columns> < asp:BoundField DataField =ProductIDHeaderText =ProductIDReadOnly =True

SortExpression =ProductID/>

< asp:BoundField DataField =ProductNameHeaderText =ProductName

ReadOnly =TrueSortExpression =ProductName/>

< asp:TemplateField HeaderText =Quantity>

< itemtemplate>

< asp:TextBox ID =TextBoxQuantityrunat =server>

< asp:LinkBut​​ton ID =删除runat =serverCommandName =删除>删除





< asp:BoundField DataField =价格DataFormatString ={0:c}HeaderText =价格

ReadOnly =True/>

< asp:BoundF ield DataField =TotalCostDataFormatString ={0:c}

HeaderText =总费用/>

< editrowstyle backcolor =#2461BF> ;

< footerstyle backcolor =#507CD1font-bold =Trueforecolor =White>

< HeaderStyle BackColor =#507CD1字体-Bold =TrueForeColor =白色/>

< pagerstyle backcolor =#2461BFforecolor =白色horizo​​ntalalign =中心>

< rowstyle backcolor =#EFF3FB>

< SelectedRowStyle BackColor =#D1DDF1Font-Bold =TrueForeColor =#333333/>

< sortedascendingcellstyle backcolor =#F5F7FB>

< sortedascendingheaderstyle backcolor =#6D95E1>

< sorteddescendingcellstyle backcolor =#E9EBEF >

&l t; sorteddescendingheaderstyle backcolor =#4870BE>






总价格< asp:标签ID =Label1runat =serverText =Label>



< asp:查看ID =View3runat =server>



< asp:查看ID =View4runat =server>



< asp:查看ID = View5runat =server>



< asp:查看ID =View6runat =server>





ConnectionStrings:DatabaseConnectionString1 %>"
SelectCommand="SELECT DISTINCT * FROM [Product] WHERE ([ProductName] LIKE ''%'' + @ProductName + ''%'')">
<SelectParameters>
<asp:ControlParameter ControlID="TextBoxProductName" Name="ProductName"
PropertyName="Text" Type="String" />
</SelectParameters>




<asp:View ID="ViewBasket" runat="server" ViewStateMode="Enabled">
Basket<asp:GridView ID="GridViewBasket"
runat="server" AutoGenerateColumns="False" AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True" CellPadding="4" ClientIDMode="AutoID"
DataKeyNames="ProductID" ForeColor="#333333"
GridLines="Horizontal" EnablePersistedSelection="True" PageIndex="1">
<alternatingrowstyle backcolor="White">
<columns> <asp:BoundField DataField="ProductID" HeaderText="ProductID" ReadOnly="True"
SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName"
ReadOnly="True" SortExpression="ProductName" />
<asp:TemplateField HeaderText="Quantity">
<itemtemplate>
<asp:TextBox ID="TextBoxQuantity" runat="server">
<asp:LinkButton ID="Remove" runat="server" CommandName="Remove">Remove


<asp:BoundField DataField="Price" DataFormatString="{0:c}" HeaderText="Price"
ReadOnly="True" />
<asp:BoundField DataField="TotalCost" DataFormatString="{0:c}"
HeaderText="Total Cost" />
<editrowstyle backcolor="#2461BF">
<footerstyle backcolor="#507CD1" font-bold="True" forecolor="White">
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center">
<rowstyle backcolor="#EFF3FB">
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<sortedascendingcellstyle backcolor="#F5F7FB">
<sortedascendingheaderstyle backcolor="#6D95E1">
<sorteddescendingcellstyle backcolor="#E9EBEF">
<sorteddescendingheaderstyle backcolor="#4870BE">



Total Price<asp:Label ID="Label1" runat="server" Text="Label">

<asp:View ID="View3" runat="server">

<asp:View ID="View4" runat="server">

<asp:View ID="View5" runat="server">

<asp:View ID="View6" runat="server">




 


 


您需要继续向容器添加产品。例如,您可以在类容器或产品列表中与产品集合进行会话。这里的会话非常重要,因此您可以在页面之间切换而不会丢失容器信息。

还有其他解决方案,您可以在页面之间保存数据(html页面是无状态的,所以你会需要有一个策略来保持容器之间的页面)。



查看这篇文章:简单购物车 [ ^ ]
You will need to keep adding products to a container. For instance, you can have an object in session with the product collection inside a class container or a list of products. Session here are important, so you can switch between pages and don''t loose your container information.
There are other solutions where you can keep your data between pages (html pages are stateless, so you will need to have a strategy to keep the container between pages).

Check this article: Simple Shopping Cart[^]


请检查以下链接: -



http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in- aspnet / [ ^ ]



简单购物车(篮子)用户控件使用ASP.NET& JavaScript(浮动,可移动和可调整大小) [ ^ ]



GridView订购页面购物车页面ASP.NET SQL [ ^ ]
Please Check Below links :-

http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/[^]

Simple Shopping Cart (Basket ) User Control using ASP.NET & JavaScript (Floating, Movable and Resizable)[^]

GridView Order Page Shopping Cart Page ASP.NET SQL[^]


这篇关于创建一个购物篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆