pkを格納する非表示の読み取り専用列を含むSqlDataSourceにバインドされたradgridがあります。その列にバインドされた値をUpdatesのストアドプロシージャに渡したいのですが、列が読み取り専用の場合のデフォルトの動作は、パラメータをsqlDataSourceに渡さないことです。私の質問は、コードビハインドに行かなくてもその値を渡す方法があるかどうかです。これが私のaspマークアップのスニペットです。
<telerik:RadGrid ID="rgEmployees" runat="server" AutoGenerateColumns="False"
DataSourceID="sdsEmployees" GridLines="None" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true">
<MasterTableView DataSourceID="sdsEmployees" EditMode="EditForms">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-Width="20px"
UniqueName="Edit" HeaderText="Edit">
<HeaderStyle Width="10px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="10px" />
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="pkWorkerID" HeaderText="pkWorkerID" UniqueName="pkWorkerID" SortExpression="pkWorkerID" Visible="false" ReadOnly="true"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ContractManagerName" HeaderText="ContractManager Name" UniqueName="ContractManagerName" SortExpression="ContractManagerName" Visible="true" ReadOnly="true"></telerik:GridBoundColumn>
<telerik:GridDropDownColumn
DataField="CODE"
HeaderText="Financial Software Name"
DataSourceID="sdsFinancialSystemGetUnassignedWorkers"
ListTextField="NAME"
ListValueField="CODE"
EnableEmptyListItem="true"
DropDownControlType="RadComboBox">
</telerik:GridDropDownColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="sdsEmployees" runat="server"
ConnectionString="" ProviderName="System.Data.SqlClient"
SelectCommand="spFinancialSystemGetWorkerMappingDataSource" SelectCommandType="StoredProcedure"
UpdateCommand="spFinancialSystemMapWorkerToCode" UpdateCommandType="StoredProcedure"
DeleteCommand="spFinancialSystemRemoveWorkerMapping" DeleteCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="hfpkSystemSupportedFinancialSoftware" Name="pkSystemSupportedFinancialSystems"
Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter ControlID="hfpkSystemSupportedFinancialSoftware" Name="pkSystemSupportedFinancialSystems"
Type="Int32" PropertyName="Value" />
<asp:Parameter Name="pkWorkerID" Type="Int32" />
<asp:Parameter Name="CODE" Type="String" />
</UpdateParameters>
<DeleteParameters>
<asp:ControlParameter ControlID="hfpkSystemSupportedFinancialSoftware" Name="pkSystemSupportedFinancialSystems"
Type="Int32" PropertyName="Value" />
<asp:Parameter Name="pkWorkerID" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
ストアドプロシージャのプロトタイプは次のようになります。
CREATE PROCEDURE [dbo].[spFinancialSystemMapWorkerToCode]
@pkWorkerID int,
@pkSystemSupportedFinancialSystems int,
@CODE nvarchar(200)
ページを実行してレコードを編集しようとすると、次のエラーが発生します。
プロシージャまたは関数'spFinancialSystemMapWorkerToCode'には、指定されていないパラメータ'@pkWorkerID'が必要です。
にreadonly="false"を設定すると、正常に機能しますが、ユーザーは不要な主キー値を編集できます。コードビハインドの回避策を知っていますが、マークアップで直接それを行う方法はありますか?ありがとう。