RadGrid OnNeedDataSource when the returned datasource is empty, I get a "Cannot find any bindable pr

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-04-05T23:27:01Z Indexed on 2010/04/05 23:33 UTC
Read the original article Hit count: 1945

Filed under:

RadGrid OnNeedDataSource when the returned datasource is empty (not null), I get a "Cannot find any bindable properties in an item from the datasource"

This is how I have my RadGrid defined in the ASP markup

<telerik:RadGrid runat="server" ID="RadGridSearchResults" 
        AllowFilteringByColumn="false"
        ShowStatusBar="true" AllowPaging="True" 
        AllowSorting="true" VirtualItemCount="10000"
        AllowCustomPaging="True" 
        OnNeedDataSource="RadGridSearchResults_NeedDataSource"
        Skin="Default" GridLines="None" ShowGroupPanel="false" 
        GroupLoadMode="Client">
        <MasterTableView Width="100%" >
        <NoRecordsTemplate>
            <asp:Label ID="LabelNoRecords" 
             runat="server" Text="No Results Found for your Query"/>
        </NoRecordsTemplate>
        </MasterTableView>
        <PagerStyle Mode="NextPrevAndNumeric" />
        <FilterMenu EnableTheming="True">
            <CollapseAnimation Duration="200" Type="OutQuint" />
        </FilterMenu>
</telerik:RadGrid>

Here is my OnNeedDataSource

protected void RadGridSearchResults_NeedDataSource(object source,
                                   GridNeedDataSourceEventArgs e)
{
 RadGridSearchResults.DataSource = GetSearchResults();
}

And here is my GetSearchResults()

private DataTable GetSearchResults()
{
DataTable dataTableResults = new DataTable();
// Get my data results -- When I get no results, I have a datable with 0 rows
return dataTableResults;
}

This works great when I have results in my DataSet and other tables of mine setup similarly work with the NoRecordsTemplate tag when results are empty. Any clue?

© Stack Overflow or respective owner

Related posts about radgrid