Prev | Current Page 815 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"


// (main purpose is to detect paging events)
bool handled = false;
CommandEventArgs cea = args as CommandEventArgs;
// handle Page event by extracting new start index
// and calling HandleSearch method which does the
// work of re-binding this control to the results
// from the web service
if (cea.CommandName == "Page")
{
PageNumber = Convert.ToInt32(cea.CommandArgument);
HandleSearch();
}
return handled;
}
private void HandleSearch()
{
SourceRequest[] sourceRequests = new SourceRequest[1];
sourceRequests[0] = new SourceRequest();
sourceRequests[0].Source = SourceType.Web;
sourceRequests[0].Count = PageSize;
//Specifies the number of results to return from offset
sourceRequests[0].Offset = PageSize * (PageNumber - 1);
//start index for returned results
//For paging, specify new offset to get next results.
//so for count of 5, to get 6-10 specify offset of 5 for page 2
sourceRequests[0].ResultFields = ResultFieldMask.All |
ResultFieldMask.DateTime;
SearchResponse searchResults =
SearchUtility.SearchLiveSearchService(
Query, sourceRequests);
OnLiveSearchSearched(new LiveSearchSearchedEventArgs(searchResults));
this.DataSource = searchResults;
this.DataBind();
}
#endregion
#region Control Creation/Rendering
private ResultItem CreateResultItem(int index, ResultItemType
itemType, bool dataBind, object dataItem)
638 CHAPTER 12 ?–  B U ILDING A COMPLEX CONTROL
{
ITemplate selectedTemplate;
switch (itemType)
{
case ResultItemType.


Pages:
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827