我有一個綁定到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