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.
Exception Details: System.IndexOutOfRangeException: Cannot find column Firstname.
Source Error:
Stack Trace:
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:
|
<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> |