This is a migrated thread and some comments may be shown as answers.

No records to display in Grid

3 Answers 207 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jo
Top achievements
Rank 1
Jo asked on 18 Feb 2011, 11:34 AM
Hello,

I am trying to use an Item Template with the Rad Grid but when the control is databound I just get a message saying 'No records to display'.  Here is my code:

ASPX:
<telerik:RadGrid ID="EcsSupplierAgreementsGrid" runat="server" AutoGenerateColumns="false"
               OnNeedDataSource="EcsSupplierAgreementsGrid_NeedDataSource"
               GridLines="None">
               <MasterTableView Width="100%">
                   <ItemTemplate>
                       <%# Eval("SupplierCode")%>
                   </ItemTemplate>
               </MasterTableView>
           </telerik:RadGrid>

ASPX.CS:
protected void EcsSupplierAgreementsGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
  EcsSupplierAgreementsGrid.DataSource = _agreement.SupplierAgreements;
}

The datasource is an IList<T>.  When I debug the line above I can see that the collection has 2 records in it.

Please can you tell me what I am doing wrong.

Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 18 Feb 2011, 11:43 AM
Hello Jo,

In order to show columns in RadGrid you need to add columns to Column collection property of TableView like below.

ASPX:
<telerik:RadGrid ID="EcsSupplierAgreementsGrid" runat="server" AutoGenerateColumns="false" OnNeedDataSource="EcsSupplierAgreementsGrid_NeedDataSource"
    GridLines="None">
    <MasterTableView Width="100%">
        <Columns>
            <telerik:GridTemplateColumn>
                <ItemTemplate>
                    <%# Eval("SupplierCode")%>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Thanks,
Princy.
0
Jo
Top achievements
Rank 1
answered on 18 Feb 2011, 11:54 AM
Cheers Princy! That works great.

I was working from the Telerik demo here. Do you think it is incorrect?
0
Princy
Top achievements
Rank 2
answered on 21 Feb 2011, 08:14 AM
Hello Jo,

That demo shows how to use the global item template feature of RadGrid for ASP.NET AJAX to create ListView/DataList like data .This is useful when you would like to display the data in a format like ListView.
Please take a look at the following demo which shows the supported column types and how to display data in RadGrid.
Grid / Column Types

Thanks,
Princy.
Tags
Grid
Asked by
Jo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jo
Top achievements
Rank 1
Share this question
or