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

Cannot find Column error

1 Answer 238 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan Xiong
Top achievements
Rank 1
Dan Xiong asked on 21 May 2010, 07:38 PM
I have two radgrids on a form with autogeneratecolumns turned off viewstate turned on I am also using the needdatasource event.  The grid is being populated in the background via a datatable that is loaded from another method.  The data is loaded based on what value the user chooses from a drop down list.  When the value is selected the datatables are then populated and the grid is rebound.  I am calling the RadGrid.Rebind() method from within the drop down's selecteditemchanged method.

When a user tries to filter using the filter control or they try to sort a column they receive an error stating that "Cannot find column"  This error occurs for every column and in both grid boxes I have searched everywhere and cannot find a solution to this.  I have included some code snippets (both grids are pretty much exactly the same in code so I only included one grid) and the error stack trace.  I have double checked to make sure that the datasource column names match the sortexpression and the DataKeyField for each column.  I made sure not to call Databind from the Page_load leaving the grid binding up to needdatasource.  I am thinking that it might be caused by me calling rebind from the dropdown's selectedindex change method but how can I force the grids to rebind without calling the ReBind method since the needdatasource is not being triggered on postback.

Cannot find column Firstname.

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.IndexOutOfRangeException: Cannot find column Firstname.

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:

[IndexOutOfRangeException: Cannot find column Firstname.]
   System.Data.DataTable.ParseSortString(String sortString) +4826462
   System.Data.DataView.CheckSort(String sort) +32
   System.Data.DataView.set_Sort(String value) +128
   Telerik.Web.UI.GridEnumerableFromDataView.PerformTransformation() +5029
   Telerik.Web.UI.GridEnumerableFromDataView.TransformEnumerable() +41
   Telerik.Web.UI.GridTableView.GetEnumerator(Boolean useDataSource, GridEnumerableBase resolvedDataSource, ArrayList dataKeysArray) +171
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +861
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +786
   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() +38
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   Telerik.Web.UI.GridTableView.DataBind() +353
   Telerik.Web.UI.GridSortCommandEventArgs.ExecuteCommand(Object source) +325
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +191
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +61
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +165
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   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

            <telerik:RadGrid ID="TrkEmpGrid" runat="server" AutoGenerateColumns="False" GridLines="None" 
                OnNeedDataSource="TrkEmpGrid_NeedDataSource" AllowFilteringByColumn="True" AllowSorting="True">  
                <GroupingSettings CaseSensitive="false" /> 
                <MasterTableView DataKeyNames="EmployeeKey" Width="100%">  
                    <RowIndicatorColumn> 
                        <HeaderStyle Width="20px"></HeaderStyle> 
                    </RowIndicatorColumn> 
                    <ExpandCollapseColumn> 
                        <HeaderStyle Width="20px"></HeaderStyle> 
                    </ExpandCollapseColumn> 
                    <Columns> 
                        <telerik:GridBoundColumn DataField="EmployeeKey" DefaultInsertValue="" HeaderText="EmployeeKey" 
                            SortExpression="EmployeeKey" UniqueName="Employee_Key" DataType="System.Int32" 
                            ReadOnly="True" Visible="false">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Lastname" DefaultInsertValue="" HeaderText="Lastname" 
                            SortExpression="Lastname" UniqueName="Lastname">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Firstname" DefaultInsertValue="" HeaderText="Firstname" 
                            SortExpression="Firstname" UniqueName="Firstname">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="EmployeeID" DefaultInsertValue="" HeaderText="Employee ID" 
                            SortExpression="EmployeeID" UniqueName="EmployeeID">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="AssignedTracks" HeaderText="Tracks" ReadOnly="True" 
                            SortExpression="AssignedTracks" UniqueName="AssignedTracks">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="ShiftName" HeaderText="Shift" ReadOnly="True" 
                            SortExpression="ShiftName" UniqueName="ShiftName">  
                        </telerik:GridBoundColumn> 
                    </Columns> 
                </MasterTableView> 
            </telerik:RadGrid> 
        </div> 

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 26 May 2010, 01:32 PM
Hi Dan,

I tried to reproduce the described issue, but to no avail. The described error occurs when the SortExpression which is set  to a column name does not exist in the datasource of the grid. Could you please open a support ticket and send us a small runnable project which demonstrates the issue. You could  open a formal support ticket from your Telerik account and attach a ZIP file there. In that way we can reproduce and pinpoint the problems you're facing on our side, understand the logic of your application and provide a solution.

Sincerely yours,
Radoslav
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.
Tags
Grid
Asked by
Dan Xiong
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or