This is a migrated thread and some comments may be shown as answers.

ControlParameter Works only for "Select" And not on "Insert"

1 Answer 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hk
Top achievements
Rank 2
Hk asked on 06 Jan 2009, 04:12 PM
Hi,
I have this Grid + Label on ASCX file:
<asp:Label runat="server" ID="hdnPId" Text="1"></asp:Label> 
 
 
<telerik:RadGrid ID="RadGrid1" Skin="Vista" Width="97%" runat="server" ShowFooter="True" 
    PageSize="7" AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" 
    OnItemDataBound="RadGrid1_ItemDataBound" GridLines="None" DataSourceID="CaptureDataSource" 
    ValidationSettings-EnableValidation="true" ValidationSettings-ValidationGroup="ConfigConfigValidationGroup"
    <HeaderContextMenu Skin="Vista" EnableTheming="True"
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
    </HeaderContextMenu> 
    <PagerStyle Mode="NextPrevAndNumeric" /> 
    <MasterTableView Width="100%" GridLines="None" CommandItemDisplay="Top" EditMode="InPlace" 
        AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" 
        HorizontalAlign="NotSet" AutoGenerateColumns="False" DataKeyNames="iCaptureId" 
        DataSourceID="CaptureDataSource"
        <CommandItemTemplate> 
            <div style="padding: 0 5px;"
                <asp:LinkButton ValidationGroup="ConfigConfigValidationGroup" ID="btnCancel" runat="server" 
                    CommandName="CancelAll" CausesValidation="false" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="./Img/Cancel.gif" />Cancel</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ValidationGroup="ConfigConfigValidationGroup" ID="Add" runat="server" 
                    CommandName="InitInsert" CausesValidation="false" Enabled='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="/Img/AddRecord.gif" />Add Capture</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ValidationGroup="ConfigConfigValidationGroup" ID="LinkButton1" CausesValidation="false" 
                    OnClientClick="javascript:return confirm('Delete Selected Capture?')" runat="server" 
                    CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="/Img/Delete.gif" />Delete</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="LinkButton3" ValidationGroup="ConfigConfigValidationGroup" runat="server" 
                    CausesValidation="false" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'>Add this Customer</asp:LinkButton>&nbsp;&nbsp; 
            </div> 
            <%-- <div style="padding: 0 5px;"
                Custom command item template&nbsp;&nbsp;&nbsp;&nbsp; 
                <asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'>Edit selected</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'>Update</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'>Cancel editing</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'>Add new</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="LinkButton3" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'>Add this Customer</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="LinkButton1" OnClientClick="javascript:return confirm('Delete all selected customers?')" 
                    runat="server" CommandName="DeleteSelected">Delete selected customers</asp:LinkButton>&nbsp;&nbsp; 
                <asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid">Refresh customer list</asp:LinkButton> 
            </div>--%> 
        </CommandItemTemplate> 
        <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </ExpandCollapseColumn> 
        <Columns> 
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UpdateImageUrl="..\Img\Update.gif" 
                EditImageUrl="..\Img\Edit.gif" InsertImageUrl="..\Img\Insert.gif" CancelImageUrl="..\Img\Cancel.gif"
            </telerik:GridEditCommandColumn> 
            <telerik:GridBoundColumn DataField="iCaptureId" DataType="System.Int32" HeaderText="iCaptureId" 
                ReadOnly="True" SortExpression="iCaptureId" UniqueName="iCaptureId"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="iPackageId" DataType="System.Int32" HeaderText="iPackageId" 
                SortExpression="iPackageId" UniqueName="iPackageId"
            </telerik:GridBoundColumn> 
            <telerik:GridDropDownColumn DataField="iCaptureType" HeaderText="iCaptureType" SortExpression="iCaptureType" 
                UniqueName="iCaptureType" DataType="System.Int32" DropDownControlType="DropDownList"
            </telerik:GridDropDownColumn> 
            <telerik:GridBoundColumn DataField="nvcAlias" HeaderText="nvcAlias" SortExpression="nvcAlias" 
                UniqueName="nvcAlias"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="nvcCtiTrunk" HeaderText="nvcCtiTrunk" SortExpression="nvcCtiTrunk" 
                UniqueName="nvcCtiTrunk"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="iBoardNumber" DataType="System.Int32" HeaderText="iBoardNumber" 
                SortExpression="iBoardNumber" UniqueName="iBoardNumber"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="iBoardTrunk" DataType="System.Int32" HeaderText="iBoardTrunk" 
                SortExpression="iBoardTrunk" UniqueName="iBoardTrunk"
            </telerik:GridBoundColumn> 
            <telerik:GridDropDownColumn DataField="nvcFrameFormat" HeaderText="nvcFrameFormat" 
                DropDownControlType="DropDownList" SortExpression="nvcFrameFormat" UniqueName="nvcFrameFormat"
            </telerik:GridDropDownColumn> 
            <telerik:GridDropDownColumn DataField="bitSummed" HeaderText="bitSummed" SortExpression="bitSummed" 
                UniqueName="bitSummed" DropDownControlType="DropDownList"
            </telerik:GridDropDownColumn> 
            <telerik:GridBoundColumn DataField="iNumOfChannels" HeaderText="iNumOfChannels" SortExpression="iNumOfChannels" 
                UniqueName="iNumOfChannels" DataType="System.Int32"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="iUsedChannels" DataType="System.Int32" HeaderText="iUsedChannels" 
                SortExpression="iUsedChannels" UniqueName="iUsedChannels"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="nvcFirstTimeSlot" HeaderText="nvcFirstTimeSlot" 
                SortExpression="nvcFirstTimeSlot" UniqueName="nvcFirstTimeSlot"
            </telerik:GridBoundColumn> 
        </Columns> 
        <EditFormSettings CaptionDataField="iCaptureId"
            <FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle> 
            <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle> 
            <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> 
            <EditColumn ButtonType="ImageButton" /> 
        </EditFormSettings> 
    </MasterTableView> 
    <ClientSettings> 
        <Selecting AllowRowSelect="True" EnableDragToSelectRows="True" /> 
    </ClientSettings> 
    <FilterMenu Skin="Vista" EnableTheming="True"
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
    </FilterMenu> 
</telerik:RadGrid> 
<asp:ObjectDataSource ID="CaptureDataSource" runat="server" DeleteMethod="Delete" 
    InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="Fill" 
    TypeName="NPEWebApplication.Configurations.RecordingConfiguration.ConfigControls.CaptureDataSource" 
    UpdateMethod="Update"
    <DeleteParameters> 
        <asp:Parameter Name="iCaptureId" Type="String" /> 
        <asp:Parameter Name="original_iCaptureId" Type="Int32" /> 
    </DeleteParameters> 
    <UpdateParameters> 
        <asp:Parameter Name="nvcFrameFormat" Type="String" /> 
        <asp:Parameter Name="iUsedChannels" Type="Int32" /> 
        <asp:Parameter Name="iBoardNumber" Type="Int32" /> 
        <asp:Parameter Name="iNumOfChannels" Type="Int32" /> 
        <asp:Parameter Name="nvcAlias" Type="String" /> 
        <asp:Parameter Name="nvcFirstTimeSlot" Type="String" /> 
        <asp:Parameter Name="iPackageId" Type="Int32" /> 
        <asp:ControlParameter ControlID="txtCaptureType" Name="iCaptureType" Type="Int32" 
            PropertyName="Text" /> 
        <asp:Parameter Name="iBoardTrunk" Type="Int32" /> 
        <asp:Parameter Name="bitSummed" Type="String" /> 
        <asp:Parameter Name="nvcCtiTrunk" Type="String" /> 
        <asp:Parameter Name="original_iCaptureId" Type="Int32" /> 
    </UpdateParameters> 
    <SelectParameters> 
        <asp:ControlParameter ControlID="hdnPId" Name="iPackageId" PropertyName="Text" 
            Type="Int32" /> 
    </SelectParameters> 
    <InsertParameters> 
        <asp:Parameter Name="nvcFrameFormat" Type="String" /> 
        <asp:Parameter Name="iUsedChannels" Type="Int32" /> 
        <asp:Parameter Name="iBoardNumber" Type="Int32" /> 
        <asp:Parameter Name="iNumOfChannels" Type="Int32" /> 
        <asp:Parameter Name="nvcAlias" Type="String" /> 
        <asp:Parameter Name="nvcFirstTimeSlot" Type="String" /> 
        <asp:ControlParameter ControlID="hdnPId" Name="iPackageId" PropertyName="Text" 
            Type="Int32" /> 
        <asp:ControlParameter ControlID="txtCaptureType" Name="iCaptureType" Type="Int32" 
            PropertyName="Text" /> 
        <asp:Parameter Name="iBoardTrunk" Type="Int32" /> 
        <asp:Parameter Name="bitSummed" Type="String" /> 
        <asp:Parameter Name="nvcCtiTrunk" Type="String" /> 
    </InsertParameters> 
</asp:ObjectDataSource> 


I define my own object datasource. When I debug the Fill method, I can see that iPackageId is 1. Nothing changes it, but when I insert a new record, the Insert method on my objectdatasource recivies iPackageId as 0. why?

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 09 Jan 2009, 07:50 AM
Hi Hk,

I suspect that the behavior you are experiencing is due to the fact that you have a field in RadGrid's edit/insert form which is with the same name as the parameter which is declared as an insert parameter. Thus RadGrid will populate this parameter when inserting or editing using automatic operations. You may consider setting this column as ReadOnly and set ForceExtractValue to None in order to prevent RadGrid to extract column's value.

Sincerely yours,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Hk
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Share this question
or