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

Grid Sorting

1 Answer 19 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 06 Jul 2012, 07:21 PM
I have the grid like this:
    <telerik:RadGrid ID="ReportsListGrid" ShowStatusBar="true" runat="server" AllowPaging="True"
        AllowSorting="true" AllowMultiRowSelection="True" PageSize="20" OnNeedDataSource="ReportsListGrid_NeedDataSource">
        <MasterTableView TableLayout="Fixed" DataKeyNames="ReportId" AutoGenerateColumns="True">
            <Columns>
                <telerik:GridBoundColumn DataField="ReportId" HeaderText="ReportId" AllowFiltering="false"
                    SortExpression="ReportId" />
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" />
                <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" />
                <telerik:GridBoundColumn DataField="ReportLocation" HeaderText="ReportLocation" SortExpression="ReportLocation" />
                <telerik:GridBoundColumn DataField="Active" HeaderText="Active" SortExpression="Active" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

And Following is how i am binding it:

        Dim reports = ReportFactory.CreateReportController().GetReports()
'reports is IList  collection
        ReportsListGrid.DataSource = reports
        ReportsListGrid.DataBind()

On the pageload grid loads correctly, but when i click on any column header for sorting it says: 

"System.IndexOutOfRangeException: Cannot find column ReportLocation."

Please help!!!!!!!!!!!

Thanks J

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 07 Jul 2012, 02:44 PM
Hello,

Please use NeedDataSource event for binding datasource to RadGrid.

Also check Grid / Advanced Data Binding For reference.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or