我有一个绑定到SqlDataSource的radgrid,它包含一个存储pk的隐藏只读列。我想将绑定到该列的值传递给更新的存储过程,但列只读时的默认行为不是将参数传递给sqlDataSource。我的问题是,是否有一种方法可以在不需要进入代码的情况下传递该值。这里是我的asp标记的片段。将readonly radgrid列的值传递给存储过程
<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”它的工作正常,但然后用户可以编辑不需要的主键值。我知道在代码背后解决问题,但是有没有办法在标记中直接使用它?谢谢。
我最后不得不因为即使ForceExtractValue =“始终” pkWorkerID没有得到这样做传递给删除存储过程 – 2009-11-05 16:49:16