LookUp & DropDown

Lookup is widely used in data presentation. For example - the master table stores the employee ID number as a key associated with related personal information in the fields.  All other tables will use the employee ID number as a key to retrieve the information fields. As important as it is, the implementation is not trivial at all. Check you favorite tool and see how they do it and how flexible they are.

Tornado provides you with means to define lookup tables where each column (field) can be a 'lookup key' or  a 'lookup value'. Study the following example and see what these few lines of code can do.

DropDown comes in 4 flavors - Free Form, SelectBoxForm, Edit and Filter. Drop lists can be obtained from Database via a query, pre-programmed list in Global.asax and in a system common file. Each has a place in different applications.

Lookup and Dropdown are not trivial tasks and the advanced lookup features in Tornado are not found anywhere.

<!--T_lookup.aspx-->

<script language="vb" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
Dim XL As New Tornado.Z()
   With XL
      .dbQP="U=7|M=g|S=10|D=nwind.mdb|Q=employees|th=Title=LookUp|gdf=0,2,16"
      .dbCommonTables = "index=EID,First,Full|sql=Select employeeid, FirstName, Firstname & ' ' & Lastname from employees"
      .dbLookUpFlds = "field=Employeeid|key=EID| lookup=Full, field=FirstName|key=First| lookup=EID, field=ReportsTo|key=EID| lookup=First"
      .ASPdbNET()
   End With
End Sub
</script>


Via the lookups - The emplyeeID field is displayed as the Full Name; The Firstname Field is displayed as the ID and the ReportsTo field is displayed as FirstName. Further more , Lookup Table(s) needs only to be defined once and used throughout all the modules. The way to define a lookup table can be via DB queries, user direct input or a <Block> delimited ascii file.

DropDown from DB, Global.asax and CommonFile

<!--T_DropDown_1.aspx-->

<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)

Application("statestext") = "Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming"
'... the above is to put the data in Application for [[statetext]]

   Dim GD As New Tornado.Getdata()
   Dim Mydb As New Tornado.Z()
   With Mydb
      .dbQP = "U=4| S=2| Ps=-1| D=Nwind.mdb| Q=employees| M=ty=SBox!SboxMacro=#2#"
      .dbTextHolder = "Title=SelectBox via DB data"
      .ASPdbNET()
      Response.Write(GD.Get_Sbox(4))
      Response.Write(GD.Get_SelectBoxSelection(4))
'...From Pre-Programmed Data
      .dbQP = "U=5| nh=t| M=ty=SBox!SboxMacro=(<<statesvalue>>~[[statestext]])"
      .dbTextHolder = "Title=SelectBox via user data"
      .ASPdbNET()
      Response.Write(GD.Get_Sbox(5))
      Response.Write(GD.Get_SelectBoxSelection(5))
'...From System Common File
      .dbQP = "U=6| nh=t| M=ty=SBox!SboxMacro=([[1-12]]~<<FrenchMonths>>)"
      .dbTextHolder = "Title=SelectBox via user data"
      .ASPdbNET()
      Response.Write(GD.Get_Sbox(6))
      Response.Write(GD.Get_SelectBoxSelection(6))
   End With
End Sub
</script>

This DropDown example use the data source in 3 different ways - DB, Global.asax and CommonFile. The serial number tag [[start-End-Inc]] produce a list from Start to End with an increment of Inc. So, all the numeric lists like months, years, days etc. will not have to be hard coded. A CommonFile is a user definable text file holding all the common data in a format of <Block_Name>...</Block_Name>.

So, there is quite a bit in Lookup and DropDown. We have collected these formats throughout the years as suggested by users.