Select List

This module allows items (DB records) in the grid to be selected and optionally supports Quantity and item(s) deletion. The selections are remembered across pages. Select and Clear All buttons are also a built-in feature.

SelectList - Select Items only

<!--T_SelectList_1.aspx-->

<script language="vb" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
   Dim GD As New Tornado.Getdata()
   Dim Sitem1 As New Tornado.Z()
   With Sitem1
      .dbQP="U=5| S=10| M=type=dh!sysindex=f!indexfld=0| D=Nwind.mdb| Q=Products| gdf=0,1|PS=10"
      .dbNameMap = "field=0|alias=Product<br>ID"
      .dbSelectedItemMacro = "(;,[]!|~/+{})macro=!0:0##! - !1! (!UnitsInStock!)|qtycol=false|buttons=true"
      .dbTextHolder = "Title=Export SelectedItem values|sub=Remember to Click 'Sel' button to register selections<br>Page forth and back and add/delete selections"
      .ASPdbNET()

'--- User Code to process Selected Items ---

      If GD.Get_SelectedItem <> Nothing Then
            Dim i As Integer
            Dim Res As String = "<P><center><table class=ts Cellspacing='1'><tr><th class=gh>Selected Items According to Macro</th></tr><tr><td class=R2>"
            Dim a() As String = .dbSelectedItem()
            If a Is Nothing Then
                  Res &= "No selection"
            Else
                  For i = 0 To UBound(a)
                        Res &= a(i) & "<br>"
                  Next i
            End If
            Response.Write(Res & "</table></center>")
      End If
   End With
End Sub
</script>

The top half of the code setup and SelectListand the bottom half process the selected items.

Another option of SelectList is the 'Quantity' option. Just add a few properties to the SelectedItemMacro to setup the Quantity column. If the quantity is blank or "0", it'll be eliminated. One user suggested that a "negative" quantity is required in order to process refund. This suggestion makes sense and it was implemented. Note that there are some data formatting code like "#2:currency#". Throughout Tornado, data fields are always presented as #field:format# where format bears the full spectrum of the VB.Net language syntax.

<!--T_SelectList_2.aspx-->

<script language="vb" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
   Dim GD As New Tornado.Getdata()
   Dim Sitem2 As New Tornado.Z()
   With Sitem2
      .dbQP="U=34| S=5| M=G| D=NWIND.Mdb| ni=b5| Th=Tit= Selected List with Quantity"
      .dbSQL = "SELECT Productid, ProductName, UnitPrice FROM Products where discontinued =false and unitprice > 0"
      .dbGridMagicCell = "field=2|tag=align=right|macro=#2:currency#"
      .dbNameMap = "field=0|alias=Id|formula=ProductId; field=2|alias|Price|formula=UnitPrice"
      .dbSelectedItemMacro = "macro=#1#:#2# | Qtycol=true | Caption=Qty | Size=3 | Raw=true| Buttons=true"
      .ASPdbNET()
   End With
'-------------- User code to Process selected data and build shopping basket ----------------
   If GD.Get_SelectedItem <> Nothing Then
      Dim c, r As Integer
      Response.Write("<hr><Center><H3>Your Shopping Basket has...</H3><TABLE class=TS cellspacing='1'><TR><TD>Item</TD><td class=gh>Product</td><td class=GH>Qty</td><td class=GH>Unit Price</td><td class=GH>Sub-Total</td></tr>")
      Dim a(,) As String = Sitem2.dbSelectedItem()
      Dim subtotal, total As Double
      Dim p() As String
      If Not (IsNothing(a)) Then
         For r = 0 To UBound(a, 2)
            p = Split(a(0, r), ":")
            subtotal = CDec(p(1)) * Val(a(1, r))
            total += subtotal
            Response.Write("<tr><td>" & r + 1 & "</td><td>" & p(0) & "</td><td>" & a(1, r) & "</td><td align=right>" & p(1) & "</td><td align=right>" & Format(subtotal, "currency") & "</td></tr>")
         Next r
         Response.Write("<tr><td colspan=4 align=right>Total</td><td align=right>" & Format(total, "currency") & "</td></tr>")
         Response.Write("</table><p><hr>")
      End If
   End if
End Sub
</script>