Hi,
I having problem in adding the variable into linkedlist. Can anyone guide me? - <div id="one" style="display: block; ">
-
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1"
-
GroupItemCount="3" OnItemCommand="ListView1_OnItemCommand">
-
<EmptyItemTemplate>
-
<td runat="server" />
-
</EmptyItemTemplate>
-
<ItemTemplate>
-
<td runat="server" style="">
-
<asp:Label ID="foodnameLabel" runat="server" Text='<%# Eval("foodname") %>' />
-
<br />
-
<asp:Label ID="foodimgLabel" runat="server" Text='<%# Eval("foodimg") %>' />
-
<br />
-
<asp:Label ID="priceLabel" runat="server" Text='<%# String.Format("{0:0.00}", Eval("price")) %>' />
-
<br />
-
<asp:Label ID="stallidLabel" runat="server" Text='<%# Eval("stallid") %>' Visible="false"/>
-
<br />
-
<asp:Button ID="addtocart" runat="server" Text='Add to cart' CommandName="addtocart" CommandArgument='<%# Eval("foodname")+ " " + Eval("price")%>' />
-
</td>
-
</ItemTemplate>
-
<AlternatingItemTemplate>
-
<td runat="server" style="">
-
<asp:Label ID="foodnameLabel" runat="server" Text='<%# Eval("foodname") %>' />
-
<br />
-
<asp:Label ID="foodimgLabel" runat="server" Text='<%# Eval("foodimg") %>' />
-
<br />
-
<asp:Label ID="priceLabel" runat="server" Text='<%# String.Format("{0:0.00}", Eval("price")) %>' />
-
<br />
-
<asp:Label ID="stallidLabel" runat="server" Text='<%# Eval("stallid") %>' Visible="false"/>
-
<br />
-
<asp:Button ID="addtocart" runat="server" Text='Add to cart' CommandName="addtocart" CommandArgument='<%# Eval("foodname")%>' />
-
</td>
-
</AlternatingItemTemplate>
-
<EmptyDataTemplate>
-
<table runat="server" style="">
-
<tr>
-
<td>
-
No data was returned.</td>
-
</tr>
-
</table>
-
</EmptyDataTemplate>
-
<LayoutTemplate>
-
<table runat="server">
-
<tr runat="server">
-
<td runat="server">
-
<table ID="groupPlaceholderContainer" runat="server" border="0" style="">
-
<tr ID="groupPlaceholder" runat="server">
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr runat="server">
-
<td runat="server" style="">
-
<asp:DataPager ID="DataPager1" runat="server" PageSize="12">
-
<Fields>
-
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
-
ShowNextPageButton="False" ShowPreviousPageButton="False" />
-
<asp:NumericPagerField />
-
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
-
ShowNextPageButton="False" ShowPreviousPageButton="False" />
-
</Fields>
-
</asp:DataPager>
-
</td>
-
</tr>
-
</table>
-
</LayoutTemplate>
-
<GroupTemplate>
-
<tr ID="itemPlaceholderContainer" runat="server">
-
<td ID="itemPlaceholder" runat="server">
-
</td>
-
</tr>
-
</GroupTemplate>
-
</asp:ListView>
-
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
-
ConnectionString="<%$ ConnectionStrings:foodcourtConnectionString %>"
-
SelectCommand="SELECT [foodname], [foodimg], [price], [stallid] FROM [foodtbl] WHERE ([stallid] = @stallid)">
-
<SelectParameters>
-
<asp:QueryStringParameter DefaultValue="1" Name="stallid"
-
QueryStringField="stallid" Type="Decimal" />
-
</SelectParameters>
-
</asp:SqlDataSource>
-
-
</div>
How can I add all the variable (foodname, price) into linkedlist when I click addtocart button?
6 1898
You have to implement the "addToCart" button's Click event in your C# or VB.NET server-side code. In this method you will add the item to your "LinkedList".
-Frinny
Currently, I had added the value in the linked list. By the way, once I refresh my page, all the variable gone. Can I know hold to hold the value?
ASP.NET works in a stateless environment. That means that all server side objects are created when the request is made....and when the response is sent to the browser all of the server side objects are destroyed.
There are a few techniques you could use to "persist" (remember/retain) the values though.
You could use Session: most commonly used when you need access to information in many pages in your website.
You could use ViewState: when you need to persist information on a single page.
You could also use cookies if you want to!
In the case of a Shopping Cart I would recommend using Session.
-Frinny
So far, I trying on cookies.
As I holding much data, thus... I still figuring out which is the better way for the implementation. Trying search on the session implementation way. You have any sample on that?
Eg.
If I add a food into shopping cart, it will hold few values such as food name and price. If I add second food, it will go into the list too.
Foodname: Fried rice Price: $4.00
Foodname: Noodles Price: $3.00
Foodname: Mushroom soup Price: $3.00
Hi Frinny,
Thanks lots. It solve my problem!!!
Easy to use compare cookies ;)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
<?...
|
by: gregerly |
last post by:
Hello,
I once again turn to this community of genius' for some help with a problem. I've got a shopping cart (which is working well so far) that I will be implementing all kinds of AJAX...
|
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...
|
by: BenKen |
last post by:
Hi all pls I'm having great difficulty in making my shopping cart work. I am a newbie in php with little understanding of it. Add to cart button doesn't work and shopping cart in general doesn't. Pls...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |