online photo proofing software
This article is part of eBook. Please use the link at bottom to jump to the rest of the eBook…
Next we create two variables. The first, intCounter, we define as an Integer; it is the counter variable that we use within our loop. The second, decRunningTotal, we define as a Decimal; it is the variable that the function will return: Dim intCounter As Integer Dim decRunningTotal As Decimal Our next step is to loop through all the rows in the DataTable using a For loop: For intCounter = 0 To objDT.Rows.Count – 1 objDR = objDT.Rows(intCounter) decRunningTotal += (objDR("Cost") * objDR("Quantity")) Next As you can see, within our loop, we increment the value of decRunningTotal as the sum of the Cost column multiplied by the Quantity column. Finally, we return decRunningTotal and terminate the function: Return decRunningTotal End Function Our last step is to write the value of decRunningTotal into the newly created Label control. You can accomplish that by adding one line of code in the Page_Load() event handler. The code addition follows, in bold: dg.DataSource = objDT dg.DataBind() lblTotal.Text = "Grand Total: $" & GetItemTotal() Session("Cart") = objDT End Sub That’s it! Our next step is to actually add items to the cart. Sit tight, we’re almost there! Adding Items to the Cart Now that viewcart.aspx is 75% complete, we can turn our attention to the employeestore.aspx page. From this page, users can select an item from the catalog, click an Add To Cart link, and instantly be redirected to the viewcart.aspx page to see a list of added items. You can included the Add To Cart functionality first by modifying the table in the employeestore.aspx page so that it includes two new rows just below the cost binding. With your cursor positioned within the row, add the text Add to Cart. Select the text and add the following code to the Link text box in the Properties Inspector: viewcart.aspx?ItemID=<%# dsEmployeeStore.FieldValue("ItemID", Container) %> When you’re done, the design will resemble Figure 28.26. Figure 28.26. Add a new Add To Cart link. [View full size image] That’s it! You’re ready to test the functionality. To test your work, select Preview in Browser by pressing the F12 key. The page displays similar to Figure 28.27. Figure 28.27. The employee store page appears complete with the Add To Cart link. [View full size image]
This article is part of eBook. To read the rest of the eBook (full version) please look at: 1.6 vac proof hack best color proof