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

[Column Name] is neither a DataColumn nor a DataRelation for table DefaultView

4 Answers 4585 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Avinash Tauro
Top achievements
Rank 1
Avinash Tauro asked on 05 Apr 2012, 04:10 PM
Hi,

I have a telerik RadGrid on a form with filters. My project is configured for .net 3.5 and everything works great including filters.

When I deploy to the test server, all the functionality except the following works as expected.

One of my columns which is boolean throws an exception whenever I try to filter on it.
Suprisingly there is another boolean column in the grid which filters perfectly.

The tags are
TAG Working Working fine on filter is
<telerik:GridCheckBoxColumn DataField="IsTrial" DataType="System.Boolean" FilterControlAltText="Filter IsTrial column"
HeaderText="IsTrial" SortExpression="IsTrial" UniqueName="IsTrial"></telerik:GridCheckBoxColumn>
TAG Failing on Filter is
<telerik:GridCheckBoxColumn DataField="IsBilled" DataType="System.Boolean" FilterControlAltText="Filter IsBilled column" HeaderText="IsBilled" SortExpression="IsBilled" UniqueName="IsBilled" ></telerik:GridCheckBoxColumn>

I see on the following error in the browser when I select filter "equal to" on the IsBilled column

Server Error in '/' Application.


IsBilled is neither a DataColumn nor a DataRelation for table DefaultView.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: IsBilled is neither a DataColumn nor a DataRelation for table DefaultView.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[ArgumentException: IsBilled is neither a DataColumn nor a DataRelation for table DefaultView.]
   System.Data.DataRowView.get_Item(String property) +1742474
   lambda_method(ExecutionScope , DataRowView ) +211
   System.Linq.WhereEnumerableIterator`1.MoveNext() +161
   System.Linq.Enumerable.Count(IEnumerable`1 source) +189
   lambda_method(ExecutionScope ) +117
   System.Linq.EnumerableExecutor`1.Execute() +103
   System.Linq.EnumerableExecutor`1.ExecuteBoxed() +23
   System.Linq.EnumerableQuery`1.System.Linq.IQueryProvider.Execute(Expression expression) +83
   Telerik.Web.UI.GridDynamicQueryable.Count(IQueryable source) +143
   Telerik.Web.UI.GridDataTableFromEnumerable.FillData35() +3353
   Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +628
   Telerik.Web.UI.GridResolveEnumerable.Initialize() +32
   Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +20
   Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, DataView dataView, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +163
   Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +71
   Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +398
   Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +158
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +316
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +545
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
   Telerik.Web.UI.GridTableView.PerformSelect() +16
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   Telerik.Web.UI.GridTableView.DataBind() +229
   Telerik.Web.UI.GridTableView.Rebind() +48
   Telerik.Web.UI.GridFilterCommandEventArgs.ExecuteCommand(Object source) +524
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +134
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +38
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +87
   Telerik.Web.UI.GridItem.FireCommandEvent(String commandName, Object commandArgument) +46
   Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +8017
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


Version Information: Microsoft .NET Framework Version:2.0.50727.3625; ASP.NET Version:2.0.50727.3634
 
----

4 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 10 Apr 2012, 02:39 PM
Hi Avinash,

Thank you for contacting us.

This erratic behavior is due to the fact that your isBilled column cannot access its required DataField. Please check your DataSource configuration closely and see if this DataField's exact name is "isBilled".

I hope this helps. I am awaiting your reply.

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
swapnil
Top achievements
Rank 1
answered on 17 Apr 2015, 08:06 AM

Hi Avinsah

  I also got this error while filtering the data ..... It not shows always but it comes after some time, while exporting and filtering .... I checked that my DataField name is same as column name and data is binding correctly , but I dont know why this error is coming

0
Eyup
Telerik team
answered on 22 Apr 2015, 07:01 AM
Hello Swapnil,

Is the problem column specific? Does it appear with other columns as well? You can run some test with the configuration from the live filtering samples:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/basic-filtering/defaultcs.aspx

If the problem remains, you can open a formal support ticket and provide further details there.

Regards,
Eyup
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Eric D. Burdo
Top achievements
Rank 2
answered on 14 Feb 2018, 02:34 PM

I recently had this issue.  In my instance, the stored procedure behind the grid was missing the [Column Name].  I had inadvertently removed it.

As soon as I put it back into the proc, it worked fine.

Roger
Top achievements
Rank 2
Iron
Iron
Iron
commented on 19 Apr 2022, 06:28 PM

I am having a similar issue but this is due to the Filtering not results being returned from Stored Proc or Select statement.

 

What is happening in my case is I am using a filter on DataSet1 in my grid and it works as expected.

 

Then I press a button and get a new result set that does NOT include that filtered column and the error is happening.

I tried to clear the filter columns and filter expression but that didn't work.

 

Not sure what is next to try.

Attila Antal
Telerik team
commented on 22 Apr 2022, 10:43 AM

Hi Roger,

There are a few things that could cause this issue. Often it is about an improper data binding (e.g. using the combination of RadGrid1.DataSource + RadGrid1.DataBind()).

While the DataBind() method would work for a basic table that only displays data, it is not supported by the Grid when you start enabling functionalities.

The recommended options for binding data are:

If you are already using one of these approaches and never calling the DataBind() method on the Grid, then the issue is related to the Grid's definition. Columns names, DataFields, the Field name of the data source, etc.. 

We can help help you figure out the problem, but for that, we need to see the complete implementation of the Grid. Also, we need to know what the COlumn names in the data source look like.

Please share more details and we will look into it.

Roger
Top achievements
Rank 2
Iron
Iron
Iron
commented on 22 Apr 2022, 02:49 PM

I have a grid that has a datasource that changes columns.  So I get a datasource, use the filter, then may get another datasource where the filter column does not exists anymore.

I would like the ability to "Remove" all filtering from grid when I set the new datasource.

Currently here is what I am doing to clear grid and get it ready for next query / datasource

 

foreach (GridColumn column in RadGrid1.MasterTableView.OwnerGrid.Columns)
            {
                column.CurrentFilterFunction = GridKnownFunction.NoFilter;
                column.CurrentFilterValue = string.Empty;
            }
            RadGrid1.MasterTableView.FilterExpression = string.Empty;
            RadGrid1.MasterTableView.SortExpressions.Clear();
            RadGrid1.DataSource = null;

 

But I still receive the error.  It's like the grid keeps the column the filter was applied on even for next datasource assignment and DataBind() or DataRebind();

Attila Antal
Telerik team
commented on 25 Apr 2022, 09:20 AM | edited

I am suspecting that setting the DataSource to null is the culprit in this case. A null object does not have columns and so, the Grid fails to access Fields that are not in the data source.

Please follow the instructions from the Clear all filters in RadGrid knowledge base article to clear all the filers.

In case you are changing the data source, be sure that the RadGrid does not have columns declared that are pointing to data source fields that do not exist in the new data source. Perhaps it is best to let the Grid generate the columns automatically based on its data source.

Please keep in mind, that binding data conditionally by calling the DataBind() will not work in this case. Make sure that you are using the NeedDataSource event for binding data and if you want to change the data source, use the DataSource property then call the Rebind() method.

RadGrid1.DataSource = new DataSourceHere(); // assing new data source
RadGrid1.Rebind(); // refresh the Grid

 

This approach, however, will only display that data until the next Rebind action. Maybe it would be better if you saved the data source in the session, and have the Grid use the Session variable in its NeedDataSource event. When you need to change the data source, change the Session variable and call the Rebind() on the Grid instance.

 

 

Tags
Grid
Asked by
Avinash Tauro
Top achievements
Rank 1
Answers by
Eyup
Telerik team
swapnil
Top achievements
Rank 1
Eric D. Burdo
Top achievements
Rank 2
Share this question
or