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

Automatic Operations & Stored Procedures

1 Answer 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lars
Top achievements
Rank 1
Lars asked on 19 Mar 2009, 02:42 PM
Hi,

We are trying to use the automatic updates, inserts etc with stored procedures. However, to many parameters sems to be sent to the procedures... Here is the markup for the grid:

<telerik:RadGrid ID="documentsGrid" DataSourceID="vegasDataSource" runat="server" 
            Skin="Office2007" AutoGenerateColumns="False" GridLines="Vertical" AllowSorting="True"
            <HeaderContextMenu> 
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
            </HeaderContextMenu> 
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="dokid,levid" DataSourceID="vegasDataSource" 
                EditMode="PopUp" AllowAutomaticInserts="True" AllowAutomaticDeletes="True" AllowAutomaticUpdates="True"
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridEditCommandColumn /> 
                    <telerik:GridTemplateColumn DataField="levid" UniqueName="customer_id" Visible="false" 
                        ReadOnly="true"
                    </telerik:GridTemplateColumn> 
                    <telerik:GridBoundColumn HeaderText="Number" UniqueName="document_id" DataField="dokid" 
                        ReadOnly="true"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Name" UniqueName="document_name" DataField="doknavn"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Path" UniqueName="document_path" DataField="Path" 
                        Visible="false"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Url" UniqueName="document_url" DataField="url" 
                        Visible="false"
                    </telerik:GridBoundColumn> 
                    <telerik:GridDropDownColumn HeaderText="Type" UniqueName="documen_type" ListTextField="type_description" 
                        ListValueField="type_name" DataField="doktype" DataSourceID="vegasDocumentTypeDataSource"
                    </telerik:GridDropDownColumn> 
                    <telerik:GridDateTimeColumn HeaderText="Revision Date" UniqueName="column4" DataField="revisjonsdato"
                    </telerik:GridDateTimeColumn> 
                    <telerik:GridDateTimeColumn HeaderText="Edited" UniqueName="column3" DataField="document_edited" 
                        ReadOnly="true"
                    </telerik:GridDateTimeColumn> 
                    <telerik:GridDateTimeColumn HeaderText="Added" UniqueName="column5" DataField="document_added" 
                        ReadOnly="true"
                    </telerik:GridDateTimeColumn> 
                    <telerik:GridCheckBoxColumn HeaderText="Expired" DataField="utgaatt" UniqueName="document_expired" 
                        Display="false" DataType="System.Boolean"
                    </telerik:GridCheckBoxColumn> 
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete"
                    </telerik:GridButtonColumn> 
                </Columns> 
                <EditFormSettings> 
                    <EditColumn UniqueName="EditCommandColumn1"
                    </EditColumn> 
                </EditFormSettings> 
            </MasterTableView> 
            <ClientSettings> 
                <ClientEvents OnRowDblClick="RowDblClick" /> 
            </ClientSettings> 
            <FilterMenu> 
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
            </FilterMenu> 
        </telerik:RadGrid> 
    </div> 
    </form> 
</body> 
</html> 
<asp:sqldatasource runat="server" id="vegasDataSource" connectionstring="<%$ ConnectionStrings:vegas %>" 
    deletecommand="vegas.usp_DocumentationsDelete" deletecommandtype="StoredProcedure" 
    insertcommand="vegas.usp_DocumentationsInsert" insertcommandtype="StoredProcedure" 
    selectcommand="vegas.usp_DocumentationSelectReportByCustomerId" selectcommandtype="StoredProcedure" 
    updatecommand="vegas.usp_DocumentationsUpdate" updatecommandtype="StoredProcedure"
    <SelectParameters> 
        <asp:QueryStringParameter DefaultValue="100630" Name="customer_id"  
            QueryStringField="customerId" Type="Int32" /> 
    </SelectParameters> 
    <DeleteParameters> 
        <asp:Parameter Name="document_id" Type="String" /> 
    </DeleteParameters> 
    <UpdateParameters> 
        <asp:QueryStringParameter DefaultValue="100630" Name="customer_id" QueryStringField="customerId" Type="Int32" />         
        <asp:Parameter Name="document_id" Type="Int32" /> 
        <asp:Parameter Name="document_name" Type="String" /> 
        <asp:Parameter Name="document_path" Type="String" /> 
        <asp:Parameter Name="documen_type" Type="String" /> 
        <asp:Parameter Name="document_url" Type="String" /> 
        <asp:Parameter Name="document_expired" Type="Boolean" /> 
        <asp:Parameter Name="document_date" Type="DateTime" /> 
        <asp:Parameter Name="document_hms" Type="String" DefaultValue="" /> 
        <asp:Parameter Name="document_msds" Type="Object" DefaultValue="" /> 
    </UpdateParameters> 
    <InsertParameters> 
        <asp:QueryStringParameter DefaultValue="100630" Name="customer_id" QueryStringField="customerId" Type="Int32" /> 
        <asp:Parameter Name="document_number" Type="String" /> 
        <asp:Parameter Name="document_name" Type="String" /> 
        <asp:Parameter Name="document_path" Type="String" /> 
        <asp:Parameter Name="documen_type" Type="String" /> 
        <asp:Parameter Name="document_url" Type="String" /> 
        <asp:Parameter Name="document_edited" Type="DateTime" /> 
        <asp:Parameter Name="document_expired" Type="Boolean" /> 
        <asp:Parameter Name="document_hms" Type="String" /> 
        <asp:Parameter Name="document_msds" Type="Object" /> 
        <asp:Parameter Direction="InputOutput" Name="document_id" Type="Int32" /> 
    </InsertParameters>  
</asp:sqldatasource> 

As you can se he stored proc gets called with to many parameters. only the first 10 parameters is supposed to be present accouding to the the proc and the SQL data source.:
exec vegas.usp_DocumentationsUpdate  
@customer_id=100630, 
@document_id=NULL
@document_name=NULL
@document_path=NULL
@documen_type=NULL
@document_url=NULL
@document_expired=NULL
@document_date=NULL
@document_hms=NULL
@document_msds=NULL
@doktype=N'Ã…'
@doknavn=N'Peva-45'
@url=N'http://lasso.norbye.no/weblicate/lasso/alsvag.no/resources/Brosjyre_Peva-45.pdf'
@Path=N'alsvaag/Brosjyre_Peva-45.pdf'
@revisjonsdato=N'06.03.2006 00:00:00'
@utgaatt=1, 
@dokid=N'100630_002'
@levid=100630 

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 23 Mar 2009, 02:44 PM
Hello Lars,

When automatic operations are enabled for grid editing, the grid passes the new values to the SqlDataSource in parameters with the same names as the DataField of each column. Therefore, you need to change the parameter names so that they be identical to the data field names for your column. In addition, you have to specify the same parameter names for your update stored procedure.

Let us know if this helps

Best Regards,
Tsvetoslav
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Lars
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or