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

[Solved] radgrid linq hierarchy question

2 Answers 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Janean Angeles
Top achievements
Rank 1
Janean Angeles asked on 31 Jul 2009, 03:42 PM
Hi,

I'm new to telerik and am getting a weird 'Expression of type 'Boolean' expected '  error when I try to load the following hierarchy page code:
<%--datasource for product radgrid--%> 
    <asp:LinqDataSource ID="LinqDataSource1" runat="server"   
        ContextTypeName="DataClassesDataContext"   
        TableName="Products"   
        Select="new (id, name)" 
        OrderBy="name">  
    </asp:LinqDataSource> 
      
      
    <%--product data grid--%> 
    <telerik:radgrid ID="RadGrid1" runat="server"   
        AllowPaging="True"   
        AllowSorting="True" 
        AutoGenerateColumns="False"   
        GridLines="None"   
        DataSourceID="LinqDataSource1"   
        DataMember="DefaultView"   
        ShowFooter="True" 
        ShowStatusBar="True" > 
        <PagerStyle Mode="NumericPages" AlwaysVisible="true" /> 
        <MasterTableView   
            AutoGenerateColumns="False"   
            DataMember="DefaultView"   
            DataKeyNames="id" 
            DataSourceID="LinqDataSource1"   
            PageSize="10"   
            EditMode="PopUp" 
            HierarchyLoadMode="ServerOnDemand">  
            <NestedViewTemplate> 
                <asp:Panel runat="server" ID="InnerContainer">  
                      
                    <%--datasources for inner radgrid--%>                    
                    <asp:LinqDataSource ID="LinqDataSource2" runat="server"   
                        EnableDelete="True"   
                        EnableUpdate="True" 
                        ContextTypeName="DataClassesDataContext"   
                        TableName="ProductToSpecialOccasions"   
                        Select="new (id, ProductID, SpecialOccasionID)" 
                        OrderBy="ProductID"   
                        Where="ProductID equals @ProductID">  
                        <WhereParameters> 
                            <asp:Parameter Name="ProductID" Type="Int64" /> 
                        </WhereParameters> 
                    </asp:LinqDataSource> 
                  
                   <%--relationship data grid--%> 
                   <telerik:radgrid ID="RadGrid2" runat="server"   
                        AllowPaging="True"   
                        AllowSorting="True" 
                        AllowAutomaticInserts="True" 
                        AllowAutomaticDeletes="True" 
                        AutoGenerateColumns="False"   
                        GridLines="None"   
                        DataSourceID="LinqDataSource2"   
                        DataMember="DefaultView"   
                        ShowFooter="True" 
                        ShowStatusBar="True">  
                        <PagerStyle Mode="NumericPages" AlwaysVisible="true" /> 
                        <MasterTableView   
                            AutoGenerateColumns="False"   
                            DataKeyNames="id" 
                            PageSize="10"   
                            EditMode="InPlace" 
                            CommandItemDisplay="Top">  
                             <DetailTables> 
                                <telerik:GridTableView DataSourceID="LinqDataSource2" Width="100%" runat="server">  
                                    <ParentTableRelation> 
                                        <telerik:GridRelationFields DetailKeyField="ParentID" MasterKeyField="id" /> 
                                    </ParentTableRelation> 
                                </telerik:GridTableView> 
                            </DetailTables> 
                            <Columns> 
                                <telerik:GridBoundColumn   
                                    UniqueName="id"   
                                    DataField="id"   
                                    DataType="System.Int64"   
                                    HeaderText="id"   
                                    ReadOnly="True"   
                                    SortExpression="id">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn   
                                    UniqueName="ProductID"   
                                    DataField="ProductID"   
                                    DataType="System.Int64"   
                                    HeaderText="ProductID"   
                                    SortExpression="ProductID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn    
                                    UniqueName="SpecialOccasionID" 
                                    DataField="SpecialOccasionID"   
                                    DataType="System.Int64"   
                                    HeaderText="SpecialOccasionID"   
                                    SortExpression="SpecialOccasionID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridButtonColumn ConfirmText="Delete this relationship?" ConfirmDialogType="RadWindow" 
                                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete" 
                                    UniqueName="DeleteColumn">  
                                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> 
                                </telerik:GridButtonColumn> 
                            </Columns> 
                        </MasterTableView> 
                    </telerik:radgrid>    
                </asp:Panel> 
            </NestedViewTemplate> 
            <ExpandCollapseColumn Visible="True"></ExpandCollapseColumn> 
            <Columns> 
                <telerik:GridBoundColumn   
                    UniqueName="id"   
                    DataField="id"   
                    DataType="System.Int64"   
                    HeaderText="id"   
                    ReadOnly="True"   
                    SortExpression="id">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn   
                    UniqueName="name"   
                    DataField="name"   
                    DataType="System.Int64"   
                    HeaderText="name"   
                    ReadOnly="True"   
                    SortExpression="name">  
                </telerik:GridBoundColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:radgrid> 

Basically I've got a many-to-many table mapping products to special occasions.  I'm trying to have an outter grid with the products and an inner-grid where the users can add or delete the special occasion relationships.  The code works if I remove the parenttablerelation and where clauses from linqdatasource2, but throws that weird bool error when I try to add them back in.  There are no bool values in the linqdatasource2 table so not sure where that value is coming from.

Does anyone see something in my code that could be causing issues?  Or is this scenario just not possible with radgrid and linq?

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 05 Aug 2009, 04:28 PM
Hi Janean,

Can you check whether the same Where clause for LinqDataSource2 works properly when the data source is related with standard MS GridView control? I suspect that the equals operator for the ProductID field may fail and expect boolean type for comparison due to some reason.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Janean Angeles
Top achievements
Rank 1
answered on 05 Aug 2009, 10:29 PM
We decided to go a different route since we couldn't get this one working.  I'll definitely give it more of a review when I have some time again.  Thanks for the response and I'll post if I find out why it didn't work.
Tags
Grid
Asked by
Janean Angeles
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Janean Angeles
Top achievements
Rank 1
Share this question
or