One more RadGridView behavior frequently requested by our clients is to display a message when there are no records to display. A typical real life scenario would be a RadGridView displaying a list of search results. When there are no results found we would like to have a message like “No results found!” displayed in RadGridView.

 

noresults

 

 

If you download the project above , you will see that if you get the EmptyDataTemplateBehavior.cs into your project, setting the empty data template will be as easy as writing a few lines of XAML :

<telerik:RadGridView x:Name="RadGridView1" > 
 <i:Interaction.Behaviors> 
 <local:EmptyDataTemplateBehavior> 
 <local:EmptyDataTemplateBehavior.EmptyDataTemplate> 
 <DataTemplate> 
 <TextBlock Text="No results found!" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding MessageVisibility}" /> 
 </DataTemplate> 
 </local:EmptyDataTemplateBehavior.EmptyDataTemplate> 
 </local:EmptyDataTemplateBehavior> 
 </i:Interaction.Behaviors> 
 </telerik:RadGridView>

 

*As you may know from my previous posts concerning attached behaviors , you will need  to add a reference to the System.Windows.Interactivity.dll.

*As always the same approach is applicable for the WPF version of RadGridView provided that you reference the right version of the System.Windows.Interactivity.dll.


Related Posts

Comments

Comments are disabled in preview mode.