Use a data list to display the list of callers. And, since the Web service method Get_Callers returns a Data Set, simply bind that data set to the data source property of the data list. My sub Bind() illustrates this:
Sub Bind()
Dim myWebSvc as Caller_Id = New Caller_Id()
Dim ds as DataSet
ds = myWebSvc.Get_Callers()
Caller_List.DataSource= ds.Tables("tbl_Caller_Id").DefaultView
Caller_List.DataBind()
End Sub
The data list is not your ordinary out of the box data list though.
We haven't even scratched the surface of the functionality of the data list or dataset in this example. These are a few simple ideas for formatting output and handling events. The desired output is
Call_Name (Name or business name of the caller)
Call_Number (The phone number from where the call originated)
Call_Date (Date and time the call was received)
We also want to link the Call_Number to a reverse directory assistance Web site so that we can find out more information about the caller than is provided from the caller id info.
So, the first line of the data list shows the data list declaration and sets a few properties. Most notable is the OnItemCommand property, which is set to handle only deleting of individual records, but could be used to handle editing as well.
Next, let's start laying out the presentation of the data list by using an ItemTemplate. The first element of the template is a label to display the Caller_Name item from the dataset.
<asp:Label id="Caller_Name" class="contents" Text='<%# Container.DataItem("Call_Name") %>'
runat="server" />
By binding (The #) the Text property of the label to the Caller_Name item from the dataset, we achieve the first line of the desired output.
But, we would also like to delete callers from the list. To do that, we add a linkbutton and set its CommandName property to delete. If we were using other commands, we would have to handle the Caller_List_ItemCommand sub a little differently, but for simplicity, we're only going to handle one ItemCommand with it.
<asp:linkbutton id="b1" runat="server" Text="Delete" CommandName = "delete" />
All right. Next we want to display the Call_Number. Mentioned earlier was functionality to link to some reverse phone number lookup on the Web in order to find out more information about the caller. The service I found is www.infousa.com. In order to directly link to the lookup feature of their Web site, we need to use this really long convoluted Url:
http://adp.infousa.com/fs?BAS_fssession=&BAS_vendor=0&bas_type=FADA&BAS_page=9&DAT_max
records=10&BAS_flag=2&BAS_flag2=1&SCH_origdb=FADP&sch_fullph
one=Call_Number
I should also qualify this by saying that there are many of these services on the Internet and most of them are free. And, this one, like all the others, isn't 100% reliable. For instance if the caller has an unlisted or new phone number, most likely there will be no information found. That said, use the hyperlink element to display the phone number and link it to the directory service:
<asp:hyperlink id="Caller_Number" class="contents" Text=''
runat="server" NavigateURL='' />
By setting the NavigateURL property to the desired hyperlink and appending the Call_Number to the end of the link, we achieve the desired results.
The final line is similar to the the Call_Name line. I use a label element and bind its Text property to the Call_Date item from the dataset.
<asp:Label id="Caller_Date" class="contents" Text='' runat="server" />