Performing the SQL Lookup
When the user clicks on the Search
button, we will formulate the SQL statement, retrieve the results, and display them in Form4. For simplicity I am creating the SQL statements directlybeware of SQL injections. (See Listing 1
for the code in VB.NET and Listing 2
In Form4, I used a List control to display the results returned from the SQL query. I need to do some configuration for the List control to make it look like the finished output in Figure 10.
Set the Decoration
property to Numbered
, so that items will display with a serial number. Set the ItemsPerPage
property to whatever number you wish. I set it to three so that, at most, three items will be shown on the screen. You also need to set the Paginate
property of Form4 to true, so that the List control can paginate its list in multiple pages (see Figure 11
|Figure 12. Displaying Form4 in UP.Simulator: By setting the ItemsPerPage property to three, only three of seven results are displayed at once. The full result set is paginated, though, unlike in Pocket IE, the numbering restarts at one on each page.|
To ensure that the items in the List control are clickable, you need to service the ItemCommand
event of the List control. When an item is clicked, we will display the next form, which is Form5 (see Figure 13
control in Form5 can be customized to display different image formats depending on the type of device that is viewing the page. The PhoneCall
control allows devices (such as cell phones) that support making phone calls to directly call a number. For devices that do not support this feature, it will display text.
When the user clicks on an item on the List control, it will display the photo of that person (the image name is the EmployeeID and stored in the current working Web directory). Other employee information is also retrieved from the database. Listing 3
shows the code to activate Form5 in VB.NET; Listing 4
shows the same in C#.
If you click on the email link on the Pocket IE, you can directly send an email using Inbox. On the UP.Simulator, you can select the "Phone:" entry and make a call (on a real phone you would be able to make a call directly).
That's it! Using the MMIT is pretty similar to programming ASP.NET. The only difference is that one of the devices that is actually accessing the application. As a mobile application developer, you need to ensure (with a lot of testing) that your application runs correctly on all devices that it is designed for.