Friday, January 20, 2012

is neither a DataColumn nor a DataRelation for table DefaultView

Problem: I get this error when I try to filter any column in my RadGrid.I am using template columns.

"is neither a DataColumn nor a DataRelation for table DefaultView"

Here is my code of a Column
<telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center" HeaderText="PO #" Visible="true">
 <ItemTemplate>
<asp:Label ID="lblPONumber" Text='<%# Eval("_PONumber") %>' runat="server">
</asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>


Solution: You have to check that DataField property is present or not.

Here is corrected Code
<telerik:GridTemplateColumn DataField="_PONumber" HeaderStyle-HorizontalAlign="Center" HeaderText="PO #" Visible="true">
 <ItemTemplate>
<asp:Label ID="lblPONumber" Text='<%# Eval("_PONumber") %>' runat="server">
</asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
</telerik:GridTemplateColumn>

4 comments:

  1. if you are still getting this error please try this things.
    - Make SortExpression and DataField with same parameter value.

    ReplyDelete
  2. HI, Facing this issue when i create the columns dynamically under a button click,and i have given datafield to each column. Any help in this case?

    ReplyDelete