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

Grid - Clicking on the Header Line to Sort

1 Answer 245 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 27 Jul 2016, 04:50 AM

Hi All,

I've a very simple page with a RadGrid, on clicking the header to sort, I get the error :-

Unable to cast object of type 'Telerik.Web.UI.RadGrid' to type 'Telerik.Web.UI.GridTableView'.

This only happened after upgrading the DLLs to 2016.2.607.40 from 2014.1.403.40
Going back to the old DLL fixes the issue.

Serverside I populate a DataTable and then use Datasource/Databind.

 

<telerik:RadGrid ID="dtgParameter" runat="server" CssClass="dataGridStyle" Width="99%" GridLines="Both" Height="100px" AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="False" AutoGenerateColumns="False" ShowFooter="false" ShowHeader="true">
                <HeaderStyle CssClass="dataGridHeader" />
                <ItemStyle CssClass="dataGridItemStyleNormal" />
                <AlternatingItemStyle CssClass="dataGridItemStyleAlt" />
                <SortingSettings EnableSkinSortStyles="false" />
                <ClientSettings EnablePostBackOnRowClick="false">
                    <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true" />
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" />
                </ClientSettings>
                <MasterTableView Name="Parameter" DataKeyNames="ParameterId" ShowHeader="true" AutoGenerateColumns="False" HierarchyLoadMode="ServerOnDemand" width="99%">
                    <Columns>
                        <telerik:GridBoundColumn HeaderStyle-ForeColor="White" DataField="ParameterId"  HeaderStyle-Font-Bold="True" SortExpression="ParameterId"  HeaderStyle-Width="0%"  HeaderText="" visible="false"/>
                        <telerik:GridBoundColumn HeaderStyle-ForeColor="White" DataField="Name"                             HeaderStyle-Font-Bold="True" SortExpression="Name"                  HeaderStyle-Width="20%" HeaderText="Name" />
                        <telerik:GridBoundColumn HeaderStyle-ForeColor="White" DataField="Comments"                         HeaderStyle-Font-Bold="True" SortExpression="Comments"              HeaderStyle-Width="80%" HeaderText="Comments" />
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Ben
Top achievements
Rank 1
answered on 28 Jul 2016, 12:08 AM
Think I founf the issue (searching on here, not Google) Few links ..

http://www.telerik.com/forums/unable-to-cast-object-of-type-telerik-web-ui-radgrid-to-type-telerik-web-ui-gridtableview

leads to

http://www.telerik.com/forums/255649-unable-to-cast-object-of-type-telerik-web-ui-radgrid-to-type-telerik-web-ui-gridtableview

and then

http://weblogs.asp.net/scottgu/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax

Which we have, need to remove this in the Web.Config :-

    <xhtmlConformance mode="Legacy"/>
Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Ben
Top achievements
Rank 1
Share this question
or