How to place the selected value from a DropDownList into a TextBox in an EditForm of a Grid

1 Answer 89 Views
Grid
Angela
Top achievements
Rank 1
Iron
Angela asked on 04 Oct 2022, 07:58 PM

I have a grid (gridTask) that has an edit form with a textbox (txtCustomer_Care_Note) and a dropdownlist (listResponsesForTasks). At this point, a user can type into the textbox and save, but I also want the user to be able to select a value from the dropdownlist and the value of their selection go into the textbox. I'm using the dropdown as "canned responses" for responses that are used often so the user doesn't have to type the response over and over.

I have this working somewhere else but with these fields being inside an edit form on the grid, I don't know how to do this. I've included my grid below and have removed quite a bit and only left what I thought was necessary. Can anyone provide an example of how I can achieve this?

<telerik:RadGrid ID="gridTasks" runat="server" >
    <MasterTableView DataKeyNames="Record_ID" EditMode="EditForms" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true">
        <Columns>
            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"</telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn DataField="Customer_Care_Note" HeaderText="Note from Customer Care"></telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings EditFormType="Template" InsertCaption="Add New Task" CaptionFormatString="Edit Task">
            <FormTemplate>
                <telerik:RadTextBox ID="txtCustomer_Care_Note" Text='<%# Bind("Customer_Care_Note") %>' runat="server" Width="100%" MaxLength="300" TextMode="MultiLine" Rows="3"></telerik:RadTextBox>
                <telerik:RadDropDownList ID="listResponsesForTasks" CssClass="w3-margin-right" runat="server" DataSourceID="sqlResponses" OnItemSelected="listResponsesForTasks_ItemSelected" AutoPostBack="true" DataTextField="Title" DataValueField="Response" Width="250px" DefaultMessage="My Responses"></telerik:RadDropDownList>

                <telerik:RadPushButton runat="server" Text='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Insert", "Update") %>' CommandName='<%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "PerformInsert", "Update")%>' CausesValidation="true" Primary="true"></telerik:RadPushButton>
                <telerik:RadPushButton runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="false" Primary="true"></telerik:RadPushButton>
            </FormTemplate>
        </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 07 Oct 2022, 04:55 PM

Hello Angela,

The scenario you have described sounds more like Cascading information. When changing the selection of the DropDownList, you'd also like to change the values of another control (TextBox). You can try the approach used for Creating Cascading ComboBoxes, but in your case, you would be updating the TextBox instead.

Please check out the Respond to events from within a radgrid edit form forum thread to learn more.

Regards,
Attila Antal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Angela
Top achievements
Rank 1
Iron
Answers by
Attila Antal
Telerik team
Share this question
or