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

Grid / Master/Detail Grids

4 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
clo
Top achievements
Rank 1
clo asked on 19 Aug 2011, 09:22 AM
Hello everyone,
I apologize now for my English!
I have a problem for connecting two RadGrid, the first concerns orders the second the details of the orders.
The error is as follows:

and the code is this:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Ordini1.aspx.cs" Inherits="Ordini_Ordini1" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

    <br />

    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"
        Width="95%" CellSpacing="0" DataSourceID="SqlDataSource1" GridLines="None"
        Skin="Outlook" PageSize="5" OnItemCommand="RadGrid1_ItemCommand"
        AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
        style="z-index: 1; left: 13px; top: 135px; position: absolute; height: 8px; width: 1296px">
                    <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
                        <Selecting AllowRowSelect="true" />
                    </ClientSettings>
            <MasterTableView  DataKeyNames="id_ordine" DataSourceID="SqlDataSource1">
            
            </MasterTableView>

           <PagerStyle Mode="NextPrevAndNumeric" />
    </telerik:RadGrid>

    <%--I did not write everything because it is a test --%>
    <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True"
        ShowStatusBar="True" PageSize="5"
                    CellSpacing="0" DataSourceID="SqlDataSource2" GridLines="None"
        Skin="Outlook" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
        style="z-index: 1; left: 5px; top: 527px; position: absolute; height: 20px; width: 1296px">
            <MasterTableView DataSourceID="SqlDataSource2" DataKeyNames="id_ordine">
           <Columns>
                <telerik:GridBoundColumn DataField="id_ordine" DataType="System.Decimal" HeaderText="id_ordine"
                    ReadOnly="True" SortExpression="id_ordine" UniqueName="id_ordine">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="QTA_COM" DataType="System.DateTime" HeaderText="QTA_COM"
                    SortExpression="QTA_COM" UniqueName="QTA_COM" DataFormatString="{0:d}">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="GRORD" HeaderText="GRORD" SortExpression="GRORD"
                    UniqueName="GRORD">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="DESCR_RORD" HeaderText="DESCR_RORD" SortExpression="DESCR_RORD"
                    UniqueName="DESCR_RORD">
                </telerik:GridBoundColumn><telerik:GridBoundColumn DataField="MATERIALE" HeaderText="MATERIALE" SortExpression="MATERIALE"
                    UniqueName="MATERIALE">
                </telerik:GridBoundColumn><telerik:GridBoundColumn DataField="LARGH" HeaderText="LARGH" SortExpression="LARGH"
                    UniqueName="LARGH">
                </telerik:GridBoundColumn>
            </Columns>
            </MasterTableView>

            <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
                <Selecting AllowRowSelect="true" />
            </ClientSettings>

            <FilterMenu EnableImageSprites="False"></FilterMenu>

            <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>

            <PagerStyle Mode="NextPrevAndNumeric" />
    </telerik:RadGrid>


    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnessioneOfficine %>"
        DeleteCommand="DELETE FROM &quot;ORDINI&quot; WHERE &quot;ID_ORDINE&quot; = ? AND &quot;ID_COMMESSA&quot; = ?"
        InsertCommand="INSERT INTO &quot;ORDINI&quot; (&quot;ID_ORDINE&quot;, &quot;ID_COMMESSA&quot;, &quot;ID_INDIRIZZO&quot;, &quot;SIGLA&quot;, &quot;DATA_ORD&quot;,
        &quot;COGNOME&quot;, &quot;NOME&quot;, &quot;TERMINE&quot;, &quot;DATA_RICEZ&quot;, &quot;ORD_TELEF&quot;, &quot;DATA_PFATT&quot;, &quot;IMP_PFATT&quot;,
        &quot;PAGAMENTO_TRAMITE&quot;, &quot;TRAS_VAL&quot;, &quot;SUPP_VAL&quot;, &quot;TOTALE_ORDINE&quot;, &quot;SCONTO&quot;, &quot;IVA_COMPRESA&quot;,
        &quot;STATO&quot;, &quot;BOLLETINO&quot;, &quot;DATA_FATT&quot;, &quot;ENTRATAM&quot;, &quot;OSSERVAZIONI&quot;, &quot;ID_RNC&quot;, &quot;FATTURA_TERZI&quot;,
        &quot;FATTURA&quot;, &quot;RESPONSABILE&quot;, &quot;ID_IND_FATTURAZIONE&quot;, &quot;TOTALE_ORDINE_IVA&quot;)
        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
        ProviderName="<%$ ConnectionStrings:ConnessioneOfficine.ProviderName %>"
        SelectCommand="SELECT &quot;ID_ORDINE&quot;, &quot;ID_COMMESSA&quot;, &quot;ID_INDIRIZZO&quot;, &quot;SIGLA&quot;, &quot;DATA_ORD&quot;, &quot;COGNOME&quot;,
        &quot;NOME&quot;, &quot;TERMINE&quot;, &quot;DATA_RICEZ&quot;, &quot;ORD_TELEF&quot;, &quot;DATA_PFATT&quot;, &quot;IMP_PFATT&quot;, &quot;PAGAMENTO_TRAMITE&quot;,
        &quot;TRAS_VAL&quot;, &quot;SUPP_VAL&quot;, &quot;TOTALE_ORDINE&quot;, &quot;SCONTO&quot;, &quot;IVA_COMPRESA&quot;, &quot;STATO&quot;, &quot;BOLLETINO&quot;, &quot;DATA_FATT&quot;, &quot;ENTRATAM&quot;, &quot;OSSERVAZIONI&quot;, &quot;ID_RNC&quot;, &quot;FATTURA_TERZI&quot;, &quot;FATTURA&quot;, &quot;RESPONSABILE&quot;, &quot;ID_IND_FATTURAZIONE&quot;, &quot;TOTALE_ORDINE_IVA&quot; FROM &quot;ORDINI&quot;"
        UpdateCommand="UPDATE &quot;ORDINI&quot; SET &quot;ID_INDIRIZZO&quot; = ?, &quot;SIGLA&quot; = ?, &quot;DATA_ORD&quot; = ?, &quot;COGNOME&quot; = ?,
        &quot;NOME&quot; = ?, &quot;TERMINE&quot; = ?, &quot;DATA_RICEZ&quot; = ?, &quot;ORD_TELEF&quot; = ?, &quot;DATA_PFATT&quot; = ?, &quot;IMP_PFATT&quot; = ?,
        &quot;PAGAMENTO_TRAMITE&quot; = ?, &quot;TRAS_VAL&quot; = ?, &quot;SUPP_VAL&quot; = ?, &quot;TOTALE_ORDINE&quot; = ?, &quot;SCONTO&quot; = ?,
        &quot;IVA_COMPRESA&quot; = ?, &quot;STATO&quot; = ?, &quot;BOLLETINO&quot; = ?, &quot;DATA_FATT&quot; = ?, &quot;ENTRATAM&quot; = ?, &quot;OSSERVAZIONI&quot; = ?,
        &quot;ID_RNC&quot; = ?, &quot;FATTURA_TERZI&quot; = ?, &quot;FATTURA&quot; = ?, &quot;RESPONSABILE&quot; = ?, &quot;ID_IND_FATTURAZIONE&quot; = ?,
        &quot;TOTALE_ORDINE_IVA&quot; = ? WHERE &quot;ID_ORDINE&quot; = ? AND &quot;ID_COMMESSA&quot; = ?">
        <DeleteParameters>
            <asp:Parameter Name="ID_ORDINE" Type="Decimal" />
            <asp:Parameter Name="ID_COMMESSA" Type="Decimal" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="ID_ORDINE" Type="Decimal" />
            <asp:Parameter Name="ID_COMMESSA" Type="Decimal" />
            <asp:Parameter Name="ID_INDIRIZZO" Type="Decimal" />
            <asp:Parameter Name="SIGLA" Type="String" />
            <asp:Parameter Name="DATA_ORD" Type="DateTime" />
            <asp:Parameter Name="COGNOME" Type="String" />
            <asp:Parameter Name="NOME" Type="String" />
            <asp:Parameter Name="TERMINE" Type="DateTime" />
            <asp:Parameter Name="DATA_RICEZ" Type="DateTime" />
            <asp:Parameter Name="ORD_TELEF" Type="String" />
            <asp:Parameter Name="DATA_PFATT" Type="DateTime" />
            <asp:Parameter Name="IMP_PFATT" Type="Decimal" />
            <asp:Parameter Name="PAGAMENTO_TRAMITE" Type="String" />
            <asp:Parameter Name="TRAS_VAL" Type="Decimal" />
            <asp:Parameter Name="SUPP_VAL" Type="Decimal" />
            <asp:Parameter Name="TOTALE_ORDINE" Type="Decimal" />
            <asp:Parameter Name="SCONTO" Type="Decimal" />
            <asp:Parameter Name="IVA_COMPRESA" Type="String" />
            <asp:Parameter Name="STATO" Type="String" />
            <asp:Parameter Name="BOLLETINO" Type="String" />
            <asp:Parameter Name="DATA_FATT" Type="DateTime" />
            <asp:Parameter Name="ENTRATAM" Type="String" />
            <asp:Parameter Name="OSSERVAZIONI" Type="String" />
            <asp:Parameter Name="ID_RNC" Type="Decimal" />
            <asp:Parameter Name="FATTURA_TERZI" Type="String" />
            <asp:Parameter Name="FATTURA" Type="String" />
            <asp:Parameter Name="RESPONSABILE" Type="String" />
            <asp:Parameter Name="ID_IND_FATTURAZIONE" Type="Decimal" />
            <asp:Parameter Name="TOTALE_ORDINE_IVA" Type="Decimal" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="ID_INDIRIZZO" Type="Decimal" />
            <asp:Parameter Name="SIGLA" Type="String" />
            <asp:Parameter Name="DATA_ORD" Type="DateTime" />
            <asp:Parameter Name="COGNOME" Type="String" />
            <asp:Parameter Name="NOME" Type="String" />
            <asp:Parameter Name="TERMINE" Type="DateTime" />
            <asp:Parameter Name="DATA_RICEZ" Type="DateTime" />
            <asp:Parameter Name="ORD_TELEF" Type="String" />
            <asp:Parameter Name="DATA_PFATT" Type="DateTime" />
            <asp:Parameter Name="IMP_PFATT" Type="Decimal" />
            <asp:Parameter Name="PAGAMENTO_TRAMITE" Type="String" />
            <asp:Parameter Name="TRAS_VAL" Type="Decimal" />
            <asp:Parameter Name="SUPP_VAL" Type="Decimal" />
            <asp:Parameter Name="TOTALE_ORDINE" Type="Decimal" />
            <asp:Parameter Name="SCONTO" Type="Decimal" />
            <asp:Parameter Name="IVA_COMPRESA" Type="String" />
            <asp:Parameter Name="STATO" Type="String" />
            <asp:Parameter Name="BOLLETINO" Type="String" />
            <asp:Parameter Name="DATA_FATT" Type="DateTime" />
            <asp:Parameter Name="ENTRATAM" Type="String" />
            <asp:Parameter Name="OSSERVAZIONI" Type="String" />
            <asp:Parameter Name="ID_RNC" Type="Decimal" />
            <asp:Parameter Name="FATTURA_TERZI" Type="String" />
            <asp:Parameter Name="FATTURA" Type="String" />
            <asp:Parameter Name="RESPONSABILE" Type="String" />
            <asp:Parameter Name="ID_IND_FATTURAZIONE" Type="Decimal" />
            <asp:Parameter Name="TOTALE_ORDINE_IVA" Type="Decimal" />
            <asp:Parameter Name="ID_ORDINE" Type="Decimal" />
            <asp:Parameter Name="ID_COMMESSA" Type="Decimal" />
        </UpdateParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnessioneOfficine %>"
        ProviderName="<%$ ConnectionStrings:ConnessioneOfficine.ProviderName %>"
        SelectCommand="SELECT [ID_ORDINE], [QTA_COM], [GRORD], [DESCR_RORD], [MATERIALE], [LARGH], [TRATTAMENTO], [ALTEZZA], [SPESSORE], [LUNGH], [KG_UTA], [FR_UTA], [QTA_PREZZO], [UTA_PREZZO],
        [SCONTO], [PREZZO_TOT], [OSSERVAZ], [STATO], [QTA_OK1], [NO_INV], [QTA_RESA], [MAGAZZINO], [QTA_PARZIALE], [DATA_RICEZIONE], [TASSO_IVA], [POSIZIONE_CAPITOLATO], [ID_COMMESSA], [ROWID]
        FROM [RORDINI] WHERE ([ID_ORDINE] = TO_NUMBER('@id_ordine'))">
        <SelectParameters>
            <asp:ControlParameter ControlID="RadGrid1"  Name="id_ordine" PropertyName="SelectedValue" Type="Decimal" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>

Thanks for the help!!

4 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 23 Aug 2011, 09:52 AM
Hi Clo,

 I suppose you are following this online demo. The code in the Page_PreRender event is used to initially select the first rows in the two grids and rebind them so that they are populated properly with data. If this does not work in your case you can remove the RadGrid2.Rebind() line of code and instead add default values for the select parameter for the queries in the second and third grid so that they are bound correctly when no row is selected.

All the best,
Marin
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
clo
Top achievements
Rank 1
answered on 01 Sep 2011, 02:01 PM
Thanks,
I have an other question if I have this error:
Error    8    'Telerik.Web.UI.GridDataItemCollection' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'Telerik.Web.UI.GridDataItemCollection' could be found (are you missing a using directive or an assembly reference?)    V:\Applicazioni Web\Solution\WebApplication1\WebApplication1\WebForm1.aspx.cs    59    33    WebApplication1
What it means...what reference or  or using directive I must add?
Thanks a lot
0
Marin
Telerik team
answered on 02 Sep 2011, 08:17 AM
Hi Clo,

 From the error message it looks like you are trying to pass a whole collection to the Add method of the items collection of the grid. Please note that the Add method accepts only a single object of type GridItem. Other than that the only assembly that you will need to reference is the Telerik.Web.UI assembly. 

Best wishes,
Marin
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
clo
Top achievements
Rank 1
answered on 02 Sep 2011, 08:23 AM
Ok Thanks!
Tags
Grid
Asked by
clo
Top achievements
Rank 1
Answers by
Marin
Telerik team
clo
Top achievements
Rank 1
Share this question
or