문제

나는 pk를 저장하는 숨겨지고 준비된 열이 포함 된 sqldatasource에 묶인 radgrid가 있습니다. 해당 열에 바인딩 된 값을 업데이트에 대한 저장 프로 시저로 전달하고 싶지만 열이 ReadOnly 일 때 기본 동작은 매개 변수를 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)

페이지를 실행하고 레코드를 편집하려고하면 다음 오류가 발생합니다.

프로 시저 또는 함수 'SPFINANCIALSYSTEMAPWERTOCODE'는 제공되지 않은 매개 변수 '@pkworkerid'를 기대합니다.

IT에서 readOnly = "false"를 설정하면 잘 작동하지만 사용자는 원하지 않는 기본 키 값을 편집 할 수 있습니다. 나는 코드 뒤에있는 일을 알고 있지만 마크 업에서 바로 할 수있는 방법이 있습니까? 감사.

도움이 되었습니까?

해결책

당신이 시도 할 수있는 다른 것은 그리드의 Datakeynames 컬렉션에 pkworkerid 필드를 추가하는 것입니다. ViewState에 저장되고 편집시 저장 프로 시저로 자동으로 전달되어야합니다.

형사

다른 팁

답은 pkworkerid 열에 대한 ForceExtractValue를 ineditMode로 설정하는 것입니다.

<telerik:GridBoundColumn DataField="pkWorkerID" HeaderText="pkWorkerID" UniqueName="pkWorkerID" SortExpression="pkWorkerID" Visible="false" ReadOnly="true" ForceExtractValue="InEditMode"></telerik:GridBoundColumn>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top