Asp.Net: Using a Usercontrol property with ObjectDataSource selectparameter

I was using a ObjectDataSource to generate a listing including paging. The ObjectDataSource used the GetItems method of my usercontrol. See this previous post. This construction works great. But now I needed to do some custom filtering in the GetItems method based on a property of the usercontrol. At first I tried to use the property directly in the GetItems method, this didn’t work the property the property returned NULL. After a small search on the internet I found the following blog post.

The solution is to dynamically add a Selectparameter that will be passed to the GetItems method. You can dynamically add Selectparameters at the OnSelecting event of the asp:ObjectDataSource,  like this:






And in you codebehind:


protected void odsListing_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
 e.InputParameters["ListingDataSourceId"] = <em>YourUsercontrolProperty</em>;
}


Now you can use YourUsercontrolProperty in the Select method of your ObjectDataSource.


public Sitecore.Collections.ItemList getItems(string <strong>myProperty</strong>)
{
  // Your selection logica
  // You can use the string <strong>myProperty</strong> for filtering
}


Hope it helps.

Sitecore: itemlist with ObjectDataSource, Listview and DataPager

For a new project I started working with Sitecore again.

I needed to create a listing of items with paging. I implemented a Listview with a ObjectDataSource and the DataPager control.




    
         <li class="clearfix">
            <a class="thumb" ID="thumnailLink"> 
                
            </a>
            <h2></a></h2>
            <span class="date">  </span>
            
            
     </li>
    
    
        Geen artikelen
    
    
        <ul ID="itemPlaceholderContainer">
            <li ID="itemPlaceholder" />
        </ul>
    
    
        <br />
    


<ul>
  <li class="paging">
        
         
             
                
             
         
        
    </li>
</ul> 





In the code behind I created the public method GetItems which returns a ChildListCollection.


namespace MyNameSpace
{
    public partial class MyUsercontrol: System.Web.UI.UserControl
    {
     
       public Sitecore.Collections.ChildList GetItems()
       {
          return Sitecore.Context.Item.GetChildren();
        }
     }
} 


The PagedControlID property of the datapager control is set to the ID of the Listview.

Asp.Net: Caching Rss feeds

For dotNetSearch.net I needed to cache the RSS feed (on the right). I did this with the .Net Cache namespace.


if(Cache.Get(RssUrl) == null)
{
 RssDocument rssFeed = RssDocument.Load(new Uri(RssUrl));
 Cache.Insert(RssUrl, XDocument.Parse(rssFeed.ToXml(DocumentType.Rss)), null, DateTime.Now.AddMinutes(15), TimeSpan.Zero);
}

XDocument rssXml = (XDocument)Cache.Get(RssUrl);


In this examle I add the RSSFeed content as object in the cache and use the url of the RSS feed as Key. The Cache will expire (and cleared) after 15 minutes.

SQLReporting service: Deployment

When deploying a project to a internal test server I got the following error:

The definition of the report ‘Main Report’ is invalid.
An unexpected error occurred in Report Processing.
Could not load file or assembly ‘Microsoft.ReportViewer.ProcessingObjectModel, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.
 

Fix this by adding a reference to ProcessingObjecdtModel.dll in you project. You can find the ProcessingObjecdtModel.dll in the GAC. The problem with the GAC is that you can’t copy the .dll from the GAC using Windows Explorer. But you can copy the DLL with Command Prompt (cmd.exe).

To do this:

    1. Run -> cmd.exe
    2. cd C:WindowsassemblyGAC_MSILMicrosoft.ReportViewer.ProcessingObjectModel 9.0.0.0__b03f5f7f11d50a3a
    3. copy Microsoft.ReportViewer.ProcessingObjectModel.dll c:locationFolder
  • This action will look like this:

     

    Copy the Microsoft.ReportViewer.ProcessingObjectModel.dll to your Bin folder or at a reference to the assembly.

    Hope it helps,

    Pieter