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

ParentTableRelation problem - Q1 2009

2 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 06 Apr 2009, 08:22 PM
Hello
I have a hierarchical radgrid which my 2 sqldatasource come from a Ms Access table. (I use ms access db from web for the first time)
I can't link my detail table view with the master table view and I don't know why
if I put a select parameter in the sql statement in my sqldatasource (of the detail table) I got an error that it's waiting for 1 parameter...
If I don't put a select parameter in the sql statement in my sqldatasource (of the detail table once again) it display every records in my detail table for each item in the mastertableview.
I'm using Q1 2009 for the first time. I usually Qx 2008 version. Does I need to change something?
Here is my code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="FEN_IMPUTATION_DETAIL.aspx.vb" Inherits="Facturation_RT.FEN_IMPUTATION_DETAIL" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title>Page sans titre</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
      <asp:SqlDataSource   
            ID="SqlDSFile"   
            runat="server"   
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"   
            SelectCommand="SELECT [FILE] FROM [Req_Somme_Imputation_Details] ORDER BY FILE">  
        </asp:SqlDataSource> 
             
        <asp:SqlDataSource   
            ID="SqlDsImputationDetail"   
            runat="server"   
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"   
            SelectCommand="SELECT * FROM [Req_Somme_Imputation_Details] WHERE FILE=@FILE" > 
           <SelectParameters> 
                <asp:Parameter Name="FILE" Type="String" /> 
           </SelectParameters> 
        </asp:SqlDataSource> 
           
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
          
        <telerik:RadGrid   
            ID="RadGrid1"   
            runat="server"   
           GridLines="None"   
            Skin="Web20" DataSourceID="SqlDSFile" > 
              
            <MasterTableView   
                datasourceid="SqlDSFile"   
                HierarchyDefaultExpanded=true   
                ExpandCollapseColumn-HeaderStyle-Width="5px" 
                 ExpandCollapseColumn-HeaderStyle-HorizontalAlign="Left" AutoGenerateColumns=true DataKeyNames="FILE">  
                
               <DetailTables> 
                    <telerik:GridTableView   
                        DataSourceID="SqlDsImputationDetail"   
                        AutoGenerateColumns=false DataKeyNames="pdebit">  
                        <ParentTableRelation> 
                            <telerik:GridRelationFields   
                                DetailKeyField="FILE"   
                                MasterKeyField="FILE" /> 
                        </ParentTableRelation>   
                        <Columns> 
                            <telerik:GridBoundColumn   
                                DataField="SommeDeCout"   
                                HeaderText="Cout"   
                                ReadOnly="True"   
                                SortExpression="SommeDeCout" /> 
                             
                        </Columns> 
                    </telerik:GridTableView> 
                </DetailTables> 
   
<ExpandCollapseColumn Visible="True">  
<HeaderStyle HorizontalAlign="Left" Width="5px"></HeaderStyle> 
</ExpandCollapseColumn> 
   
            </MasterTableView> 
        </telerik:RadGrid> 
             
          
    </div> 
    </form> 
</body> 
</html> 
 
Thank you

2 Answers, 1 is accepted

Sort by
0
Myriam
Top achievements
Rank 1
answered on 07 Apr 2009, 02:46 PM

I found that when I put a parameter directly in my sqldatasource, it's doing the filter but it doesn,t associate the detailtableview to the mastertableview. I mean that it put my 3 records (from the filter) for each file.

 <asp:SqlDataSource   
            ID="SqlDsImputationDetail"   
            runat="server"   
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"   
            SelectCommand="SELECT * FROM [Req_Somme_Imputation_Details] WHERE FILE='030-Notre-Dame-Lac-Etchemin'" > 
           <SelectParameters> 
                <asp:Parameter Name="FILE" Type="String" /> 
           </SelectParameters> 
        </asp:SqlDataSource> 
For example
For my file 030-Notre-Dame-Lac-Etchemin, I have 3 records in the Req_Somme_imputation. So for all files in my SqlDSFile, it display the 3 records below it.
Thank you
0
Myriam
Top achievements
Rank 1
answered on 07 Apr 2009, 03:26 PM
Sorry
My problem wasn't telerik. it was the access to MsAccess. I can't use @ for my parameter
so this is working:

SelectCommand

="SELECT * FROM [Req_Somme_Imputation_Details] WHERE FILE=?" >

 

Tags
Grid
Asked by
Myriam
Top achievements
Rank 1
Answers by
Myriam
Top achievements
Rank 1
Share this question
or