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

Add new record doesn't work in batch edit mode

0 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 29 Oct 2019, 07:43 PM

Currently I am trying to use teleriks automatic CRUD on the front-end. I am currently using batch edit mode, and the editing/updating works great. However, whenever I try to insert a record it does not work. I get an error of to many arguments specified, which is not true. When I look at the values, it seems like it is trying to insert data from the previous row and not the new. 

 

<%@ Page Title="" Language="C#" MasterPageFile="~/BPO.Master" AutoEventWireup="true" CodeBehind="frmCCP.aspx.cs" Inherits="BPO.frmCCP" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" PostBackControls="btnExport, AddNewRecordButton, SaveChangesIcon">
    </telerik:RadAjaxManager>
    <h1 class="text-Center" style="text-align:center; color:red;">CCP Information</h1>
    <br />
    <br />
    <div class="myGridClass">
        <telerik:RadGrid RenderMode="Lightweight" runat="server" ID="grdCCP" AllowPaging="True" PageSize="10" FilterType="HeaderContext" AllowFilteringByColumn="true"
            AllowAutomaticInserts="true" DataSourceID="grdCCPSource" AllowAutomaticUpdates="true" EnableHeaderContextFilterMenu="true" EnableHeaderContextMenu="true" OnItemInserted="grdCCP_ItemInserted" OnItemUpdated="grdCCP_ItemUpdated">
            <ExportSettings Excel-Format="ExcelML" OpenInNewWindow="true" ExportOnlyData="true" FileName="CCPReport" IgnorePaging="true"></ExportSettings>
            <ClientSettings>
                <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" />
            </ClientSettings>
            <MasterTableView DataKeyNames="CPP_ID" Width="100%" Height="100%" CssClass="myGridClass" AutoGenerateColumns="false" AllowFilteringByColumn="True" CommandItemDisplay="Top" AllowAutomaticUpdates="true" EditMode="Batch" BatchEditingSettings-EditType="Cell">
                <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="true" ShowRefreshButton="false" />
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="Created_Date" SortOrder="Descending" />
                </SortExpressions>
                <Columns>
                    <telerik:GridBoundColumn DataField="CPP_ID" HeaderText="CCP ID" InsertVisiblityMode="AlwaysHidden">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Customer" ItemStyle-CssClass="customerddl" DataField="Customer"
                        FilterControlAltText="Filter Customer" SortExpression="Customer" FilterCheckListEnableLoadOnDemand="true" AutoPostBackOnFilter="true" GroupByExpression="Customer Group By Customer" CurrentFilterFunction="Contains">
                        <HeaderStyle Width="125px" />
                        <ItemTemplate>
                            <telerik:RadLabel runat="server" ID="lblCustomer" Text='<%# DataBinder.Eval(Container.DataItem, "Customer") %>' DefaultInsertValue="NULL"></telerik:RadLabel>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadDropDownList RenderMode="Lightweight" runat="server" ID="Update_Customer" DataSourceID="CustomerDataSource" DataTextField="Name" DataValueField="Name" DefaultMessage="-Select-" CssClass="req-field"></telerik:RadDropDownList>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <telerik:RadDropDownList RenderMode="Lightweight" runat="server" ID="Insert_Customer" DataSourceID="CustomerDataSource" DataTextField="Name" DataValueField="Name" DefaultMessage="-Select-" CssClass="req-field"></telerik:RadDropDownList>
                        </InsertItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="Cust_NAMC_ID" CurrentFilterFunction="Contains" HeaderText="Customer NAMC" DefaultInsertValue="NULL">
                        <HeaderStyle Width="115px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Program" CurrentFilterFunction="Contains" HeaderText="Program" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="CCP" ItemStyle-CssClass="customerddl" DataField="Po_Type_ID"
                        FilterControlAltText="Filter CCP"  FilterCheckListEnableLoadOnDemand="true" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                        <HeaderStyle Width="125px" />
                        <ItemTemplate>
                           <telerik:RadLabel runat="server" ID="lblCCP" Text='<%# DataBinder.Eval(Container.DataItem, "Po_Type_ID") %>'></telerik:RadLabel>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadDropDownList RenderMode="Lightweight" runat="server" ID="Update_CCP" DataSourceID="CCPDataSource" DataTextField="Name" DataValueField="Name" DefaultMessage="-Select-" CssClass="req-field"></telerik:RadDropDownList>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <telerik:RadDropDownList RenderMode="Lightweight" runat="server" ID="Insert_CCP" DataSourceID="CCPDataSource" DataTextField="Name" DataValueField="Name" DefaultMessage="-Select-" CssClass="req-field"></telerik:RadDropDownList>
                        </InsertItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="Part_No" HeaderText="Component PN" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="110px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Part_Name" HeaderText="Component Name" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="175px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Date_Rcvd" HeaderText="Date Rec'd" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="New_Price" HeaderText="New Price" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Tooling_Price" HeaderText="Tooling" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="RFQ_Num" HeaderText="Toyota Letter Reference RFQ #" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="150px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Eff_From" HeaderText="Effective From" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Eff_To" HeaderText="Effective To" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FG_Part_No" HeaderText="Finished Good PN" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="150px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FG_Part_Name" HeaderText="Finished Good Name" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="200px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Ship_From" HeaderText="Ship From" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="175px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Ship_To" HeaderText="Ship To" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="175px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="TG_NAMC" HeaderText="TG NAMC" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Vendor_CD" HeaderText="TG Vendor Code" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PO_NUM" HeaderText="PO NO" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="REV_NO" HeaderText="Rev" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Buyer_Name" HeaderText="Buyer" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="135px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Manager_Name" HeaderText="Manager" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="125px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="BU" HeaderText="Business Unit" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="SAM" HeaderText="SAM" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="125px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="RFQ_To_CUST" HeaderText="RFQ to Customer" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Quoted_Date" HeaderText="Quoted Date" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PO_From_FG" HeaderText="PO from FG" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PO_RCVD_Date" HeaderText="PO Received Date" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PO_Eff_Date" HeaderText="Effective Date" CurrentFilterFunction="Contains" DefaultInsertValue="NULL">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Created_Date" HeaderText="Created Date" CurrentFilterFunction="Contains">
                        <HeaderStyle Width="100px" />
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
    <asp:SqlDataSource ID="grdCCPSource" runat="server" ConnectionString="<%$ ConnectionStrings:SalesTest %>"
        SelectCommand="BPO.Get_CPP_Data" SelectCommandType="StoredProcedure" UpdateCommand="BPO.Update_CPP_Data" UpdateCommandType="StoredProcedure" InsertCommand="BPO.Inserts_CPP_Data" OnInserting="grdCCPSource_Inserting" InsertCommandType="StoredProcedure">
        <UpdateParameters>
            <asp:Parameter Name="CPP_ID" DbType="Int32" Direction="Input" />
            <asp:Parameter Name="Customer" DbType="String" Direction="Input" />
            <asp:Parameter Name="Cust_NAMC_ID" DbType="String" Direction="Input" />
            <asp:Parameter Name="Program" DbType="String" Direction="Input" />
            <asp:Parameter Name="PO_Type_ID" DbType="String" Direction="Input" />
            <asp:Parameter Name="Part_No" DbType="String" Direction="Input" />
            <asp:Parameter Name="Part_Name" DbType="String" Direction="Input" />
            <asp:Parameter Name="Date_Rcvd" DbType="String" Direction="Input" />
            <asp:Parameter Name="New_Price" DbType="Decimal" Direction="Input" />
            <asp:Parameter Name="Tooling_Price" DbType="Decimal" Direction="Input" />
            <asp:Parameter Name="RFQ_Num" DbType="String" Direction="Input" />
            <asp:Parameter Name="Eff_From" DbType="String" Direction="Input" />
            <asp:Parameter Name="Eff_To" DbType="String" Direction="Input" />
            <asp:Parameter Name="FG_Part_No" DbType="String" Direction="Input" />
            <asp:Parameter Name="FG_Part_Name" DbType="String" Direction="Input" />
            <asp:Parameter Name="Ship_From" DbType="String" Direction="Input" />
            <asp:Parameter Name="Ship_To" DbType="String" Direction="Input" />
            <asp:Parameter Name="TG_NAMC" DbType="String" Direction="Input" />
            <asp:Parameter Name="Vendor_CD" DbType="Int32" Direction="Input" />
            <asp:Parameter Name="PO_NUM" DbType="String" Direction="Input" />
            <asp:Parameter Name="REV_NO" DbType="String" Direction="Input" />
            <asp:Parameter Name="Buyer_Name" DbType="String" Direction="Input" />
            <asp:Parameter Name="Manager_Name" DbType="String" Direction="Input" />
            <asp:Parameter Name="BU" DbType="String" Direction="Input" />
            <asp:Parameter Name="SAM" DbType="String" Direction="Input" />
            <asp:Parameter Name="RFQ_To_CUST" DbType="String" Direction="Input" />
            <asp:Parameter Name="Quoted_Date" DbType="String" Direction="Input" />
            <asp:Parameter Name="PO_From_FG" DbType="String" Direction="Input" />
            <asp:Parameter Name="PO_RCVD_Date" DbType="String" Direction="Input" />
            <asp:Parameter Name="PO_Eff_Date" DbType="String" Direction="Input" />
            <asp:Parameter Name="Created_Date" Type="DateTime" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Customer" DbType="String" Direction="Input" />
            <asp:Parameter Name="Cust_NAMC_ID" DbType="String" Direction="Input" />
            <asp:Parameter Name="Program" DbType="String" Direction="Input" />
            <asp:Parameter Name="PO_Type_ID" DbType="String" Direction="Input" />
            <asp:Parameter Name="Part_No" DbType="String" Direction="Input" />
            <asp:Parameter Name="Part_Name" DbType="String" Direction="Input" />
            <asp:Parameter Name="Date_Rcvd" DbType="String" Direction="Input" />
            <asp:Parameter Name="New_Price" DbType="Decimal" Direction="Input" />
            <asp:Parameter Name="Tooling_Price" DbType="Decimal" Direction="Input" />
            <asp:Parameter Name="RFQ_Num" DbType="String" Direction="Input" />
            <asp:Parameter Name="Eff_From" DbType="String" Direction="Input" />
            <asp:Parameter Name="Eff_To" DbType="String" Direction="Input" />
            <asp:Parameter Name="FG_Part_No" DbType="String" Direction="Input" />
            <asp:Parameter Name="FG_Part_Name" DbType="String" Direction="Input" />
            <asp:Parameter Name="Ship_From" DbType="String" Direction="Input" />
            <asp:Parameter Name="Ship_To" DbType="String" Direction="Input" />
            <asp:Parameter Name="TG_NAMC" DbType="String" Direction="Input" />
            <asp:Parameter Name="Vendor_CD" DbType="Int32" Direction="Input" />
            <asp:Parameter Name="PO_NUM" DbType="String" Direction="Input" />
            <asp:Parameter Name="REV_NO" DbType="String" Direction="Input" />
            <asp:Parameter Name="Buyer_Name" DbType="String" Direction="Input" />
            <asp:Parameter Name="Manager_Name" DbType="String" Direction="Input" />
            <asp:Parameter Name="BU" DbType="AnsiStringFixedLength" Direction="Input" />
            <asp:Parameter Name="SAM" DbType="String" Direction="Input" />
            <asp:Parameter Name="RFQ_To_CUST" DbType="String" Direction="Input" />
            <asp:Parameter Name="Quoted_Date" DbType="String" Direction="Input" />
            <asp:Parameter Name="PO_From_FG" DbType="String" Direction="Input" />
            <asp:Parameter Name="PO_RCVD_Date" DbType="String" Direction="Input" />
            <asp:Parameter Name="PO_Eff_Date" DbType="String" Direction="Input" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="CustomerDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SalesTest %>"
        SelectCommand="SELECT DISTINCT [Name] FROM [BPO].[M_Code] WHERE Type_ID = '1' ORDER BY [Name] ASC"></asp:SqlDataSource>
        <asp:SqlDataSource ID="CCPDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SalesTest %>"
        SelectCommand="SELECT DISTINCT [Name], [PO_Type_ID] FROM [SPIRE].[M_PO_TYPE] WHERE Po_Type_ID in (4,5,6,7,8) ORDER BY [Name] ASC"></asp:SqlDataSource>
</asp:Content>

 

My stored Proc is as follows: 

USE [Sales]
GO
/****** Object:  StoredProcedure [BPO].[Inserts_CPP_Data]    Script Date: 10/29/2019 11:44:10 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
-- =============================================
-- Author:      <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [BPO].[Inserts_CPP_Data]
    -- Add the parameters for the stored procedure here
    @Customer varchar(20),
    @Cust_NAMC_ID varchar(10),
    @Program varchar(10),
    @PO_Type_ID varchar(10),
    @Part_No varchar(20),
    @Part_Name varchar(50),
    @Date_Rcvd varchar(50),
    @New_Price decimal(18,4),
    @Tooling_Price decimal(18,4),
    @RFQ_Num varchar(20),
    @Eff_From varchar(50),
    @Eff_To varchar(50),
    @FG_Part_No varchar(20),
    @FG_Part_Name varchar(50),
    @Ship_From varchar(50),
    @Ship_To varchar(50),
    @TG_NAMC varchar(50),
    @Vendor_CD int,
    @PO_NUM varchar(50),
    @REV_NO varchar(20),
    @Buyer_Name varchar(200),
    @Manager_Name varchar(200),
    @BU char(2),
    @SAM varchar(50),
    @RFQ_To_CUST varchar(50),
    @Quoted_Date varchar(50),
    @PO_From_FG varchar(50),
    @PO_RCVD_Date varchar(50),
    @PO_Eff_Date varchar(50)
 
AS
BEGIN
 
SET @PO_Type_ID = (Select [PO_Type_ID] from [SPIRE].M_PO_TYPE where [Name] = @PO_Type_ID)
 
Insert Into [SPIRE].T_CPP
(
    [Cust_NAMC_ID],
    [Customer],
    [Program],
    [PO_Type_ID],
    [Part_No],
    [Part_Name],
    [Date_Rcvd],
    [New_Price],
    [Tooling_Price],
    [RFQ_Num] ,
    [Eff_From],
    [Eff_To],
    [FG_Part_No],
    [FG_Part_Name],
    [Ship_From],
    [Ship_To],
    [TG_NAMC],
    [Vendor_CD],
    [PO_NUM],
    [REV_NO],
    [Buyer_Name],
    [Manager_Name],
    [BU],
    [SAM],
    [RFQ_To_CUST],
    [Quoted_Date],
    [PO_From_FG],
    [PO_RCVD_Date],
    [PO_Eff_Date] ,
    [Created_Date]
    )
 
    VALUES
(
    @Cust_NAMC_ID,
    @Customer,
    @Program,
    @PO_Type_ID,
    @Part_No,
    @Part_Name,
    @Date_Rcvd,
    @New_Price,
    @Tooling_Price,
    @RFQ_Num,
    @Eff_From,
    @Eff_To,
    @FG_Part_No,
    @FG_Part_Name,
    @Ship_From,
    @Ship_To,
    @TG_NAMC,
    @Vendor_CD,
    @PO_NUM,
    @REV_NO,
    @Buyer_Name,
    @Manager_Name,
    @BU,
    @SAM,
    @RFQ_To_CUST,
    @Quoted_Date,
    @PO_From_FG,
    @PO_RCVD_Date,
    @PO_Eff_Date,
    GETDATE()
)
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
 
END

No answers yet. Maybe you can help?

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