need some help with shopping cart

N

nicholas

Hello,

Got a kind of e-commerce site.
There are products with product options, such as color, size, etc

All are defined a table:
tbl_products: the table with the products.
tbl_options: the table with the options (Columns are: optionID,
parentoptionID, optionname).

Ex. of content for tbl_options:
1, 0, color
2, 1, yellow
3, 1, green
4, 1, blue
5, 0, size
6, 5, small
7, 5, medium
8, 5, large

I want a webpage that generates the product info from tbl_products (that's
no problem)
and that generates a way of selecting the options from tbl_options.
The user can select the options and add the product to the shopping cart.

So, a dynamically created dropdown would be great, but it could also be done
with a dynamically created radiobuttonlist.
Ex:
color: [here comes dropdown1 with: yellow, green, blue]
size: [here comes dropdown2 with: small, medium, large]

It should be an obvious problem as almost all e-commerces offer the ability
to select options for a product.

I really hope someone can help me implement this in asp.NET, or at least
tell me where to find a tutorial.

NB: I code in VB.net.

Thanks in advance,
Nic
 
G

Guest

Nick,

One way to solve this is to use a stored procedure to perform 2 selects (one
for the colors, one for the sizes) and fill a DataSet. This should generate
two DataTables in the DataSet.

Next, simply add two DropDownList controls to your webform.

In the code, simply perform databinding like so:

MyDropDownList.DataSource = MyDataSet.Tables[0];
MyDropDownList.DataBind();

MyOtherDropDownList.DataSource = MyDataSet.Tables[1];
MyOtherDropDownList.DataBind();

Keep in mind that you only have to DataBind the first time the user views
the page if you have ViewState enabled. So you should wrap those two with
the following:

if(!Page.IsPostBack){
// CALL FUNCTION TO DO DATA RETRIEVAL AND BINDING
}
 
G

Guest

Asp.net has a radiobuttonlist web server control which you can databind it
will any array of values or from a database. You would need to set it
datasource property = to your datasource and then bind the control
 
N

nicholas

First, thank you for your reply!

What you explain would be no problem to do, indeed.
But the problem is that a product can have more than 2 options or none and
not always color and size.

In fact in my backofice, when I add a new product, I can add as much options
as I need for the product.
Another example could be what you get when you configure a computer on
Dell.com.
For 1 model you have at least 10 options: monitor, processor, HD, etc
So, just like on Dell, I would need dropdownboxes to be generated
dynamicaly, depending on the options for that product, found in the
tbl_options.


I should also say that the tbl_options contains a column "productID".

Don't hesitate to ask me more, if it's not clear !

Thanks a lot,
Nic

Charles Chen said:
Nick,

One way to solve this is to use a stored procedure to perform 2 selects (one
for the colors, one for the sizes) and fill a DataSet. This should generate
two DataTables in the DataSet.

Next, simply add two DropDownList controls to your webform.

In the code, simply perform databinding like so:

MyDropDownList.DataSource = MyDataSet.Tables[0];
MyDropDownList.DataBind();

MyOtherDropDownList.DataSource = MyDataSet.Tables[1];
MyOtherDropDownList.DataBind();

Keep in mind that you only have to DataBind the first time the user views
the page if you have ViewState enabled. So you should wrap those two with
the following:

if(!Page.IsPostBack){
// CALL FUNCTION TO DO DATA RETRIEVAL AND BINDING
}

nicholas said:
Hello,

Got a kind of e-commerce site.
There are products with product options, such as color, size, etc

All are defined a table:
tbl_products: the table with the products.
tbl_options: the table with the options (Columns are: optionID,
parentoptionID, optionname).

Ex. of content for tbl_options:
1, 0, color
2, 1, yellow
3, 1, green
4, 1, blue
5, 0, size
6, 5, small
7, 5, medium
8, 5, large

I want a webpage that generates the product info from tbl_products (that's
no problem)
and that generates a way of selecting the options from tbl_options.
The user can select the options and add the product to the shopping cart.

So, a dynamically created dropdown would be great, but it could also be done
with a dynamically created radiobuttonlist.
Ex:
color: [here comes dropdown1 with: yellow, green, blue]
size: [here comes dropdown2 with: small, medium, large]

It should be an obvious problem as almost all e-commerces offer the ability
to select options for a product.

I really hope someone can help me implement this in asp.NET, or at least
tell me where to find a tutorial.

NB: I code in VB.net.

Thanks in advance,
Nic
 
N

nicholas

Thx for your reply.

I could do this, indeed, but the control should be generated dynamically.
I replied to Charles' message with more details on what I want to do, as I
think I was not understood 100%.

I already tried to implement something with the radiobuttonlist, but I
didn't got it working and I would prefer dropdownboxes ;-)

Check out my reply on Charles' message, you may understand better what I
want to do.

Anyway, thank again for your help,
Nic

Tampa .NET Koder said:
Asp.net has a radiobuttonlist web server control which you can databind it
will any array of values or from a database. You would need to set it
datasource property = to your datasource and then bind the control



nicholas said:
Hello,

Got a kind of e-commerce site.
There are products with product options, such as color, size, etc

All are defined a table:
tbl_products: the table with the products.
tbl_options: the table with the options (Columns are: optionID,
parentoptionID, optionname).

Ex. of content for tbl_options:
1, 0, color
2, 1, yellow
3, 1, green
4, 1, blue
5, 0, size
6, 5, small
7, 5, medium
8, 5, large

I want a webpage that generates the product info from tbl_products (that's
no problem)
and that generates a way of selecting the options from tbl_options.
The user can select the options and add the product to the shopping cart.

So, a dynamically created dropdown would be great, but it could also be done
with a dynamically created radiobuttonlist.
Ex:
color: [here comes dropdown1 with: yellow, green, blue]
size: [here comes dropdown2 with: small, medium, large]

It should be an obvious problem as almost all e-commerces offer the ability
to select options for a product.

I really hope someone can help me implement this in asp.NET, or at least
tell me where to find a tutorial.

NB: I code in VB.net.

Thanks in advance,
Nic
 
G

Guest

It seems like what you need is a relationship table that's going to link
products with the applicable options. This is more of a SQL question than it
is a .Net framework question.

On the .Net side, the way to go about it is still to use mutliple selects
within a single procedure to generate a DataSet with multiple tables (one for
each option type like size, color).

In your database, I suggest a table tbl_ProductOptions as such:

(I'm using an imaginary schema, but I think you can translate yourself)
CREATE TABLE tbl_ProductOptions (
ProductId int NOT NULL,
OptionId int NOT NULL,
CONSTRAINT PK_ProductOptions PRIMARY KEY(ProductId, OptionId),
<add foreign key constraints here to the products table and the options table>
)

For example, you could have a product identified by ID 1. This product
could then have multiple options associated with it. For example,

1-2
1-5
1-6

Where 2 means a color option, 5 means a size option, and 6 means a shipping
option. You need to create a table to represent the one-to-many relationship
between products and options.

After that, you need a stored procedure to do a select for each option type
that is associated with the product to generate a DataSet with a DataTable
for each option type.

Just my recommendation.
 
G

Guest

Also,

Keep in mind that the control is not necessarily *generated* dynamically.

It is *populated* dynamically based on the data source that it is bound to.
What you really need to solve is how you plan on creating that data source
(see my previous post).
 
N

nicholas

OK.
I understand and I think I can manage it.

There's just that "generating" vs. "populating" thing:
If on my product webpage I have a product with the options you mensioned:
color, size and shipping for ex.
Than I should have 3 dropdowns on my page. So, how would you say to the
page that there should be 3 dropdowns?
I cannot just put 3 dropdowns on my page and populate it, because sometimes
there will be just 1 dd. or none at all. So that's what I meant with
generating or better "creating" the dropdowns dynamically.

I'm not sure, but maybe I could do this with a placeholder in a reapeater or
something like this...

Hope I'm not taking too much of your time.

THX,
Nic
(ps: leaving now, will be back tomorrow)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,811
Latest member
SaulFernan

Latest Threads

Top