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

[Solved] ServerOnDemand works but changing to ServerBind fails

2 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fred
Top achievements
Rank 1
Fred asked on 05 Aug 2009, 03:21 PM
This is kind of weird, I must have something not configured right.

In my hierarchical radgrid, if I leave mastertable and the detailstable and the detailstable to that one as ServerOnDemand the grid works fine.

If I change it to ServerBind or if I say HierarchyDefaultExpanded="true" then get an error.

ItemID is neither a DataColumn nor a DataRelation for table Request.


System.ArgumentException: ItemID is neither a DataColumn nor a DataRelation for table Request.



Now ItemID is a column in a datatable and Request is a datatable. The error is correct though. There is no ItemID in the Request DataTable. I don't understand why it's looking in that table though.

MasterTable binds to Request DataTable which does not have ItemID, it has ADMRequestID
DetailsTable1 binds to a RequestItems DataTable which does have an ItemID
and DetailsTable2 binds to a ClaimItems DataTable which also has an ItemID

So why it all works on ServerOnDemand but fails if I change it to ServerBind is very weird. I have the parent relations setup, but again, only works on ServerOnDemand.

<telerik:RadGrid ID="grdSearchResults"  
                                        runat="server"  
                                        Skin="Office2007"  
                                        Visible="true"
                                        <SelectedItemStyle BackColor="Wheat" /> 
                                        <%--<HeaderStyle BackColor="White" Font-Underline="true" Font-Italic="true" />--%> 
                                    <MasterTableView Name="Request" 
                                        AutoGenerateColumns="false"  
                                        DataKeyNames="ADMRequestID" 
                                        HierarchyLoadMode="ServerOnDemand" 
                                         
                                        PagerStyle-AlwaysVisible="true" 
                                        AllowSorting="true" 
                                        AllowPaging="true" 
                                        PageSize="50" > 
                                        <HeaderStyle /> 
                                        <ExpandCollapseColumn CollapseImageUrl="~/Images/SinglePlus.gif" ExpandImageUrl="~/Images/SinglePlus.gif"></ExpandCollapseColumn> 
                                        <Columns> 
                                            <telerik:GridBoundColumn DataField="ADMRequestID" Visible="false" /> 
                                            <telerik:GridBoundColumn DataField="IsRACRequest" Visible="false" /> 
                                            <telerik:GridTemplateColumn HeaderText="Request #" DataField="UserRequestID"
                                                <ItemTemplate> 
                                                    <asp:HyperLink ID="hlRequestID" runat="server" Font-Size="Small" NavigateUrl='<%# UrlRequestLink(Container.Cells(2).Text, Container.Cells(3).Text) %>' Text='<%# Eval("UserRequestID") %>' />     
                                                </ItemTemplate> 
                                            </telerik:GridTemplateColumn> 
                                            <telerik:GridBoundColumn DataField="Status" HeaderText="Status" /> 
                                             
                                            <telerik:GridBoundColumn DataField="DateOfLetter" HeaderText="Date Of Letter" DataFormatString="{0:d}" /> 
                                            <telerik:GridBoundColumn DataField="DateDue" HeaderText="Due Date" DataFormatString="{0:d}" /> 
                                            <telerik:GridBoundColumn DataField="DateMailed" HeaderText="Date Mailed" DataFormatString="{0:d}" /> 
                                            <telerik:GridBoundColumn DataField="SearchFound" Visible="false" /> 
                                        </Columns>     
                                        <%--<SelfHierarchySettings ParentKeyName="ADMRequestID" KeyName="ItemID" />--%> 
                                         
                                        <DetailTables> 
                                            <telerik:GridTableView Name="RequestItems" 
                                                AutoGenerateColumns="false"  
                                                DataKeyNames="ItemID" 
                                                HierarchyLoadMode="ServerOnDemand"
                                                <Columns> 
                                                    <telerik:GridBoundColumn DataField="ItemID" Visible="false" /> 
                                                    <telerik:GridBoundColumn DataField="ADMRequestID" Visible="false" /> 
                                                    <telerik:GridBoundColumn DataField="ItemType" HeaderText="Type" /> 
                                                    <telerik:GridBoundColumn DataField="ItemUserID" Visible="false" /> 
                                                    <telerik:GridBoundColumn DataField="IsRACType" Visible="false" /> 
                                                    <telerik:GridTemplateColumn HeaderText="Description" DataField="Description"
                                                        <ItemTemplate> 
                                                            <asp:HyperLink ID="hlClaimID" runat="server" Font-Size="Small" NavigateUrl='<%# UrlItemLink(Container.Cells(2).Text, Container.Cells(4).Text, Container.Cells(6).Text) %>' Text='<%# Eval("Description") %>' />     
                                                        </ItemTemplate> 
                                                    </telerik:GridTemplateColumn> 
                                                    <telerik:GridBoundColumn DataField="ItemDate" HeaderText="Date" DataFormatString="{0:d}" /> 
                                                    <telerik:GridBoundColumn DataField="SearchFound" Visible="false" /> 
                                                    <telerik:GridBoundColumn DataField="Duplicate" Visible="false" /> 
                                                </Columns> 
                                                <ParentTableRelation> 
                                                    <telerik:GridRelationFields DetailKeyField="ADMRequestID" MasterKeyField="ADMRequestID" /> 
                                                </ParentTableRelation> 
                                                <DetailTables> 
                                                    <telerik:GridTableView Name="ClaimItems" 
                                                    AutoGenerateColumns="false"  
                                                    DataKeyNames="ItemID" 
                                                    HierarchyLoadMode="ServerOnDemand"
                                                        <ParentTableRelation> 
                                                            <telerik:GridRelationFields DetailKeyField="ADMClaimID" MasterKeyField="ItemID" /> 
                                                        </ParentTableRelation> 
                                                        <Columns> 
                                                            <telerik:GridBoundColumn DataField="ItemID" Visible="false" /> 
                                                            <telerik:GridBoundColumn DataField="ADMClaimID" Visible="false" /> 
                                                            <telerik:GridBoundColumn DataField="ItemType" HeaderText="Type" /> 
                                                            <telerik:GridBoundColumn DataField="ItemUserID" Visible="false" /> 
                                                            <telerik:GridBoundColumn DataField="IsRACType" Visible="false" /> 
                                                            <telerik:GridTemplateColumn HeaderText="Description" DataField="Description"
                                                                <ItemTemplate> 
                                                                    <asp:HyperLink ID="hlClaimID" runat="server" Font-Size="Small" NavigateUrl='<%# UrlItemLink(Container.Cells(2).Text, Container.Cells(4).Text, Container.Cells(6).Text) %>' Text='<%# Eval("Description") %>' />     
                                                                </ItemTemplate> 
                                                            </telerik:GridTemplateColumn> 
                                                            <telerik:GridBoundColumn DataField="ItemDate" HeaderText="Date" DataFormatString="{0:d}" /> 
                                                            <telerik:GridBoundColumn DataField="SearchFound" Visible="false" /> 
                                                        </Columns>                                                 
                                                    </telerik:GridTableView> 
                                                </DetailTables> 
                                            </telerik:GridTableView> 
                                        </DetailTables> 
                                    </MasterTableView> 
                                     
                                </telerik:RadGrid> 



Protected Sub grdSearchResults_DetailTableDataBind(ByVal source As ObjectByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles grdSearchResults.DetailTableDataBind 
        LoadGrid(e.DetailTableView.Name) 
    End Sub 
 
 
    Protected Sub grdSearchResults_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdSearchResults.NeedDataSource 
        LoadGrid() 
    End Sub 
 
Protected Sub LoadGrid(Optional ByVal TableName As String = ""
                 With Me.grdSearchResults 
                    If TableName <> "" Then 
                        .DataSource = SearchResults.Tables(TableName) 
                    Else 
                        .DataSource = SearchResults 
                    End If 
End Sub 


The SearchResults is a DataSet with 3 DataTables

Request is the first DataTable
Columns: ADMRequestID

RequestItems is the next DataTable
Columns: ItemID, ADMRequestID

ClaimItems is the next DataTable
Columns: ItemID, ADMClaimID

2 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 10 Aug 2009, 08:01 AM
Hi Fred,

Try binding the MasterTableView to the corresponding table explicitly:

    Protected Sub grdSearchResults_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdSearchResults.NeedDataSource    
        LoadGrid(grdSearchResults.MastarTableView.Name)    
    End Sub    
 

I hope this helps.

Best wishes,
Tsvetoslav
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
Fred
Top achievements
Rank 1
answered on 11 Aug 2009, 02:33 PM
I ended up fixing this error by removing the DataKeyNames from the each of the DetailsView tables.  Once I blanked those out I was able to use ServerBind. Kind of weird, guess that's the way it's intended. 
Tags
Grid
Asked by
Fred
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Fred
Top achievements
Rank 1
Share this question
or