No records text in RadGridView without using behaviors

5 posts, 0 answers
  1. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 01 Sep 2010 Link to this post


    RadControls version


    .NET version


    Visual Studio version


    programming language


    browser support

    all browsers supported by RadControls

    Most often we want to show a "No records found..." message on the grid when there are no records bound to the grid. This project demonstrates how to create a custom RadGridView to handle this.

    The custom grid takes care of
    - not showing the no records message on load on a empty grid
    - showing the "no records" message when no data is bound (probably as a result of searh results)
    - hiding the "no records" message.

    The grid has 2 dependency properties
    - HasNoRecords (bool?)
    - NoRecordsText (string)

    Of the above 2 properties, HasNoRecords needs be to bound to a bool? value in the views view model (or code behind) which identifies if there are any records. The NoRecordsText may or may not be data bound. It can even be hardcoded as below.

    Useage is as simple as below

    <NoRecordsGridView:CustomRadGrid Grid.Row="0" ItemsSource="{Binding DataItems}" AutoGenerateColumns="True" HasNoRecords="{Binding HasNoRecords}" NoRecordsText="No data found..."/>

    Please provide your feedback on this.

  2. Milan
    Milan avatar
    1989 posts

    Posted 01 Sep 2010 Link to this post

    Hello Ganesh Shivshankar,

    Thank you sharing this code with the community. Your Telerik points have been updated. 

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. sandy
    sandy avatar
    55 posts
    Member since:
    Aug 2010

    Posted 01 Feb 2012 Link to this post

    when i run ur code am getting this error.

    The type 'CustomRadGrid' was not found. [Line: 10 Position: 168].

    in my application am added the norecordsgridview namespace and customradgrid class file also.
    am getting the property content is set more then once error for this line.
    here am sending my code.

    <telerik:RadGridView x:Name="rgvMeterReads" ItemsSource="{Binding Data}" HorizontalAlignment="Left" Grid.Column="0" Grid.Row="0" Margin="0,0,0,0" ShowGroupPanel="False" AlternateRowBackground="#FFFF66" AlternationCount="2" ShowColumnHeaders="True" RowIndicatorVisibility="Collapsed" RowHeight="15" Width="1000" Height="auto">
                                    <Style TargetType="telerik:GridViewHeaderCell">
                                        <Setter Property="Background" Value="Transparent"/>
                                        <Setter Property="Foreground" Value="Black" />
                                        <Setter Property="BorderBrush" Value="Blue"/>
                                    <Style TargetType="telerik:GridViewHeaderRow">
                                        <Setter Property="Background" Value="#66CCFF" />
                                    </Style >

                        <NoRecordsGridView:CustomRadGrid Grid.Row="0" ItemsSource="{Binding DataItems}" AutoGenerateColumns="True" HasNoRecords="{Binding HasNoRecords}" NoRecordsText="No data found..."/>
  4. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 26 Dec 2012 Link to this post


    I have modified the project slightly and update it with the latest binaries. You can find it attached.

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Vitro
    Vitro avatar
    3 posts
    Member since:
    Feb 2011

    Posted 11 Oct 2018 Link to this post



    Is there a built in functionality for this in the RadGrid nowadays?



Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.