473,289 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

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 1157
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
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...
0
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.