Parameter in UpdateParameter for type GridViewDataComboBoxColumn not pulling value for Update Command

82 Views Asked by At

Seems that when I am using the following update

UpdateCommand="UPDATE XXXXXX SET MedicationType = @MedicationType, BillingCode = @BillingCode, ServiceType = @ServiceType,
                                    Charge = @Charge, Reimbursement = @Reimbursement,MinLength = @MinLength,MaxLength=@MaxLength,
                                       Units = @Units, RateCode = @RateCode, RevenueCode = @RevenueCode,PlaceOfService = @PlaceOfService,
                                    Taxonomy = @Taxonomy ,UpdatedDate = GETDATE(),UpdatedBy = @UserID WHERE ID = @ID"
                    deleteCommand="Delete from tblFeeScheduleDetails where ID = @ID "

I am trying to grab the vlues from Service Type and it is not working. The following is the code for GridViewDataComboBoxColumn

<dx:GridViewDataComboBoxColumn Caption="ServiceType" FieldName="ServiceType" >

                                                                    <EditItemTemplate>
                      <dx:ASPxGridLookup ID="ddlServiceType" runat="server" SelectionMode="Multiple"  DataSourceID="serviceTypes" ClientInstanceName="ddlServiceType"
                                            KeyFieldName="Description" OnInit="Lookup_Init" TextFormatString="{0}" MultiTextSeparator=", " GridViewProperties-Settings-ShowColumnHeaders="true"
                                            GridViewProperties-Settings-ShowFilterRow="false">
                                            <Columns>
                                                <dx:GridViewCommandColumn ShowSelectCheckbox="True" Width="30px" SelectAllCheckboxMode="AllPages" />
                                                <dx:GridViewDataColumn FieldName="Description" Width="200px" />
                                            </Columns>
                                            <GridViewProperties>
                                                <Templates>
                                                    <StatusBar>
                                                        <table class="OptionsTable" style="float: right">
                                                            <tr>
                                                                <td>
                                                                    <dx:ASPxButton ID="Close" runat="server" AutoPostBack="false" Text="Close">
                                                                        <ClientSideEvents Click="function(s, e) {
                                                                            ddlServiceType.ConfirmCurrentSelection();
                                                                            ddlServiceType.HideDropDown();
                                                                            ddlServiceType.Focus();
                                                                            return false;
                                                                        }" />
                                                                    </dx:ASPxButton>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </StatusBar>
                                                </Templates>
                                                <Settings VerticalScrollableHeight="250" VerticalScrollBarMode="Auto" />
                                                <SettingsPager Mode="ShowAllRecords" AlwaysShowPager="false"></SettingsPager>
                                            </GridViewProperties>
                                        </dx:ASPxGridLookup>
                </EditItemTemplate>
                                                                     </dx:GridViewDataComboBoxColumn>

Everything that I have tried does not store the values that I am changing when I cick update on the front end.

1

There are 1 best solutions below

0
On

In order to pass a bound value from a template control (ASPxGridLookup ID="ddlServiceType"), you need to define the Two-Way Binding Expression for the related bindable property. So, if you use ASPxGridLookup in the (SelectionMode="Multiple") mode and have the (TextFormatString="{0}" MultiTextSeparator=", ") configuration, you can automatically grab the multiple selected values (from the {0} - FieldName="Description" column) separated by (MultiTextSeparator=", ") by adding the (Text='<%#Bind("ServiceType")%>') expression:

<dx:GridViewDataComboBoxColumn ... FieldName="ServiceType" >
    <EditItemTemplate>
        <dx:ASPxGridLookup ID="ddlServiceType" ... Text='<%#Bind("ServiceType")%>'
            SelectionMode="Multiple" TextFormatString="{0}" MultiTextSeparator=", ">
        </dx:ASPxGridLookup>
    </EditItemTemplate>
</dx:GridViewDataComboBoxColumn>

If you need to get the multiple selected values in some another format, use this approach, handle the necessary of ASPxGridView.RowInserting/RowUpdating events, retrieve values from template controls and pass them into e.NewValues dictionary.