need some help with shopping cart

Discussion in 'ASP .Net' started by nicholas, Nov 30, 2004.

  1. nicholas

    nicholas Guest

    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
     
    nicholas, Nov 30, 2004
    #1
    1. Advertising

  2. 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" wrote:

    > 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
    >
    >
    >
     
    =?Utf-8?B?Q2hhcmxlcyBDaGVu?=, Nov 30, 2004
    #2
    1. Advertising

  3. 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" wrote:

    > 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
    >
    >
    >
     
    =?Utf-8?B?VGFtcGEgLk5FVCBLb2Rlcg==?=, Nov 30, 2004
    #3
  4. nicholas

    nicholas Guest

    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" <> wrote in message
    news:...
    > 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" wrote:
    >
    > > 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
    > >
    > >
    > >
     
    nicholas, Nov 30, 2004
    #4
  5. nicholas

    nicholas Guest

    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" <> wrote in
    message news:...
    > 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" wrote:
    >
    > > 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
    > >
    > >
    > >
     
    nicholas, Nov 30, 2004
    #5
  6. 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.
     
    =?Utf-8?B?Q2hhcmxlcyBDaGVu?=, Nov 30, 2004
    #6
  7. 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).
     
    =?Utf-8?B?Q2hhcmxlcyBDaGVu?=, Nov 30, 2004
    #7
  8. nicholas

    nicholas Guest

    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)

    "Charles Chen" <> wrote in message
    news:...
    > 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).
     
    nicholas, Nov 30, 2004
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Max
    Replies:
    0
    Views:
    306
  2. Craig

    ASP Shopping Cart Help Needed

    Craig, Jul 17, 2003, in forum: ASP General
    Replies:
    1
    Views:
    116
    Ray at
    Jul 17, 2003
  3. isaac2004

    help with using shopping cart totals

    isaac2004, Feb 24, 2006, in forum: ASP General
    Replies:
    7
    Views:
    150
    Paxton
    Feb 25, 2006
  4. OM
    Replies:
    2
    Views:
    359
    Cdn Tech
    Sep 7, 2003
  5. Stuincalif
    Replies:
    1
    Views:
    251
    Keith Keller
    Feb 1, 2006
Loading...

Share This Page