473,474 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

shopping cart binding to datagrid

Hi,

I'm wondering if there is a way to bind to datagrid or a gridview the
items in an arraylist. These items all have vars such as price,
qty..etc? (besides putting in a datagrid or datatable first).

ex.
ArrayList alShoppingCart = shoppingCart.GetCurrentItems;
alShoppingCart contains an array list of Item objects.

Thanks
Maz.

May 12 '06 #1
3 1161
You can bind to an ArrayList because its an IEnumerable. Or am I not
understanding?

May 12 '06 #2

Flinky Wisty Pomm wrote:
You can bind to an ArrayList because its an IEnumerable. Or am I not
understanding?


You can but my arraylist contains objects of the other type (items)
since it's a shopping cart. Each item has public fields (Id, Price,
Qty...etc). How do you tell my gridview to bind to those fields?

Thanks
MA

May 15 '06 #3
Like this:
<asp:GridView runat="server">
<BoundField HeaderText="Item Code" DataField="Id" />
<BoundField HeaderText="Price" DataField="Price" HtmlEncode="false"
DataFormatString="{0:c}" />
<BoundField HeaderText="Quantity" DataField="Qty" />
</asp:GridView>

Note the HtmlEncode attribute on the price field - if you don't include
it, your data format string won't work because the value of Price is
treated as a string and not a numeric value.

HTH

-- flink

May 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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...
1
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...
1
by: Jia Sun | last post by:
hello , everybody , i need a similar program , just like fancyimport.com if possible, pls contact me ,thank you very much . inchina@gmail.com
0
by: psb | last post by:
imagine a shopping cart application. I am on the product details page. this page has a cart summary on the right hand side of the page. the cart summary is a webcontrol that sits in the aspx page...
1
by: Trevor Oakley | last post by:
I have been learning ASPNET from ASP.NET Kick Start (Stephen Walther), and I have hit a problem with adding a DropDownList onto a DataGrid. I have added some first results for searches at...
2
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...
7
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...
1
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 <?...
3
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.