I have a grid doing an inline update to a stored procedure. But I do not know how to get the value of the grid column passed as a parmater to the stored procedure using VS12 VB aspx. Here is partial code.
<telerik:RadGrid ID="dgPlans" GridLines="None" runat="server" AllowAutomaticDeletes="True"
AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True"
AutoGenerateColumns="False" CellSpacing="0" Width="716px" DataSourceID="sqlPlans"
<telerik:GridDropDownColumn DataField="PlanId" DataSourceID="sqlGetPlans"
HeaderText="Plan" ListTextField="ippPlan" ListValueField="PlanId"
UniqueName="ippPlanId" ColumnEditorID="GridDropDownColumnEditor1">
</telerik:GridDropDownColumn>
UpdateCommand="sp_Update_Plan" UpdateCommandType="StoredProcedure"
<UpdateParameters>
<asp:Parameter Name="EffectiveDate" Type="Datetime"></asp:Parameter>
<asp:Parameter Name="ExpirationDate" Type="Datetime"></asp:Parameter>
<asp:Parameter Name="Split" Type="Decimal"></asp:Parameter>
<asp:Parameter Name="Level" Type="String"></asp:Parameter>
<asp:Parameter Name="PlanId" Type="Int32"></asp:Parameter>
</UpdateParameters>
Like I said the stored procedure name on my SQL box is sp_Update_Plan and it takes several params. But what is used as the @ piece of the parameter? What part of the radgrid become the @piece to pass to my SP? The uniquename? The Datafield has to match the @parameter?
All the examples I have seen just have the SQL statement in the updatecommand I need to use as stored procedure.
thanks,
6 Answers, 1 is accepted
Please check this Code Library which shows an example to Update/Insert/Delete with stored procedures.
Update/Insert/Delete with stored procedures and SqlDataSource control
Thanks,
Princy.
thanks.
Can I get a zip file or link to the project. I am still unable to pass sql parmaters vi a datasource from a grid. All the names are matching is there something else?
Thanks
You could use the link below:
http://www.telerik.com/community/code-library/aspnet-ajax/grid/automatic-updates-with-different-parameter-names.aspx
Regards,
Maria Ilieva
the Telerik team
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
<ItemStyle CssClass="MyImageButton"></ItemStyle>
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="ippPlanAssignID" DataType="System.Int32" FilterControlAltText="Filter ippPlanAssignID column" HeaderText="Plan Assign ID" ReadOnly="True" SortExpression="ippPlanAssignID" UniqueName="ippPlanAssignID" Visible="false" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="EmplID" DataType="System.Int32" FilterControlAltText="Filter EmplID column" HeaderText="Emp. ID:" ReadOnly="False" SortExpression="EmplID" UniqueName="EmplID" Visible ="false">
</telerik:GridBoundColumn>
<telerik:GridDropDownColumn DataField="ippPlanID" DataSourceID="sqlGetPlans"
HeaderText="Plan Description" ListTextField="ippPlanDesc" ListValueField="ippPlanID"
UniqueName="PlanDesc" ReadOnly="False" ColumnEditorID="GridDropDownColumnEditor1">
</telerik:GridDropDownColumn>
<telerik:GridDropDownColumn DataField="OrgLevelID" DataSourceID="sqlGetOrgLevels"
HeaderText="Org Level" ListTextField="OrgLevelDescription" ListValueField="OrgLevelID"
UniqueName="CategoryID" ColumnEditorID="GridDropDownColumnEditor2">
</telerik:GridDropDownColumn>
<telerik:GridDateTimeColumn DataField="EffectiveDate" DataType="System.DateTime" PickerType="DatePicker" FilterControlAltText="Filter EffectiveDate column" HeaderText="Effective Date" SortExpression="EffectiveDate" UniqueName="EffectiveDate">
</telerik:GridDateTimeColumn>
<telerik:GridDateTimeColumn DataField="ExpirationDate" DataType="System.DateTime" PickerType="DatePicker" FilterControlAltText="Filter ExpirationDate column" HeaderText="Expiration Date" SortExpression="ExpirationDate" UniqueName="ExpirationDate">
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn DataField="SplitFactor" DataType="System.Decimal" FilterControlAltText="Filter SplitFactor column" HeaderText="Split Factor" SortExpression="SplitFactor" UniqueName="SplitFactor">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="DeleteColumn">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton"></ItemStyle>
</telerik:GridButtonColumn>
</Columns>
====================================================
<InsertParameters>
<asp:Parameter Direction="Input" Name="EmplID" Type="Int32"></asp:Parameter>
<asp:Parameter Direction="Input" Name="PlanId" Type="Int32"></asp:Parameter>
<asp:Parameter Direction="Input" Name="OrgLevelID" Type="String" />
<asp:Parameter Direction="Input" Name="EffectiveDate" Type="DateTime" />
<asp:Parameter Direction="Input" Name="ExpirationDate" Type="DateTime" />
<asp:Parameter Direction="Input" Name="SplitFactor" Type="Decimal" />
</InsertParameters>
Does it have something to do with the grid combo boxes ListTextField or ListValueField? Which does it pass to the stored proc?
Thanks
Try attaching an event handler to the Insert event of the grid and inspect the e.Command.Parameters collection to see what parameters are being sent to the stored procedure and what value they have. In addition, you can also try setting a DefaultValue for the insert parameters and see if that makes any difference.
All the best,
Maria Ilieva
the Telerik team