AddFromDB.aspx
Previous  Top  Next

The soul purpose of this page is to use the ProductID value passed as a URL parameter to get all the relevant product information from the database and add the item to the cart, and then the user is redirected to the cart display page (covered later).

Begin by adding a cart control, as in the product.aspx page this is done by clicking on the insert location in the page and then clicking the WebXeL Cart icon clip0011 in the insert bar, the cart dialog will then appear, give the cart an ID of "Cart1" the same as on the product.aspx page, if you give it a different ID it will store it's contents and state in a different session from the other cart, this is because you can have multiple carts active within the same user session by using different ID's.

Next insert an Add To Cart From Database control by clicking the clip0009 icon in the insert bar, the following dialog will then appear:

clip0065

Define the values as shown:

·Select the "ConStr" connection from the ConnectionString dropdown box.  
·Select the "web_Products" query from the DBtable dropdown box, this is where the data will come from.  
·Define the ParamName as "ProdID" this is the URL Parameter name the control will get the ProductID from, you defined this previously on the product.aspx page.  
·Click the folder icon for the AfterAddURL and browse and select the cart.aspx page in the sites cart folder, this is where the user is redirected to once the item has been added to the cart.  
·Select "OleDb" for the DataBaseType  
·Select the "ProductID" field for the SelectorField, this is the database field the control will search within for the product id value passed in the ProdID URL Parameter.  
· Select "Cart1" from the Cart dropdown box, this is how the control knows which cart to add the item to when your using multiple carts.  

Next click "Field Mappings" in the left section of the dialog and it will change to show the field mappings, define them as shown below:

clip0066

Using this dialog add the following field mappings:

·Cart Field "ID" to get it's value from Database Field "PartNo"  
·Cart Field "Description" to get it's value from Database Field "Description"  
·Cart Field "RawCost" to get it's value from Database Field "Price"  

There is no need to define a quantity as it will default to 1 if not specified, you can however specify any value you like for any cart field if required.

Once you have added the 3 field mappings click "OK" and the following icon clip0009 should appear in the page where your cursor was positioned.

The entire contents of the design surface of the page should be only the 2 icons for the Cart and AddFromDB controls as shown below:

clip0011clip0009

Next: BatchAdd.aspx