public override void DataBind() { //base.DataBind(); MonoXCacheManager cacheManager = MonoXCacheManager.GetInstance(TweetsCacheKey, this.CacheDuration); KeyValuePair <SyndicationFeed, int> bindContainer = cacheManager.Get <KeyValuePair <SyndicationFeed, int> >(ProfileName, TweetsCount); if (bindContainer.Value == 0) { try { TweetsCount = TweetsCount.HasValue ? TweetsCount : 10; var url = string.Format("http://api.twitter.com/1/statuses/user_timeline.rss?screen_name={0}&count={1}", ProfileName, TweetsCount); SyndicationFeed feed = LoadFrom(url); bindContainer = new KeyValuePair <SyndicationFeed, int>(feed, feed.Items.Count()); cacheManager.Store(bindContainer, ProfileName, TweetsCount); } catch (Exception ex) { log.Error(ex); } try { if (Page.User.Identity.IsAuthenticated) { //Save the Tweets to the DB Guid listId = Guid.Empty; if (!Guid.Empty.Equals(ListId)) { listId = ListId; } else if (!String.IsNullOrEmpty(ListName)) { listId = BaseMonoXRepository.GetInstance().GetFieldValue <Guid>(ListFields.Title, ListName, ListFields.Id); } if (Guid.Empty.Equals(listId) && !String.IsNullOrEmpty(ListName)) { //Create a List ListEntity list = ListRepository.GetInstance().CreateNewList(); list.Title = ListName; list.UserId = SecurityUtility.GetUserId(); list.ListType = 0; ListRepository.GetInstance().SaveEntity(list, true); listId = list.Id; } if (!Guid.Empty.Equals(listId)) { foreach (var item in bindContainer.Key.Items) { Guid urlId = BaseMonoXRepository.GetInstance().GetFieldValue <Guid>(ListItemLocalizationFields.ItemUrl, item.Id, ListItemLocalizationFields.Id); if (!Guid.Empty.Equals(urlId)) { break; //Suppose that we have imported upcoming tweets } ListItemEntity listItem = ListRepository.GetInstance().CreateNewListItem(listId); listItem.DateCreated = Convert.ToDateTime(item.PublishDate.ToString()); listItem.ItemTitle = HtmlFormatTweet(item.Title.Text); listItem.ItemUrl = item.Id; ListRepository.GetInstance().SaveEntity(listItem); } } } } catch (Exception ex) { log.Error(ex); } } //Note: We need to perform the in-memory paging List <SyndicationItem> items = bindContainer.Key.Items.Skip(pager.CurrentPageIndex * pager.PageSize).Take(pager.PageSize).ToList(); PagerUtility.BindPager(pager, DataBind, lvItems, items, bindContainer.Value); if (HideIfEmpty) { this.Visible = (bindContainer.Value != 0); } }