How do I use a DropDown list for a TelerikForm item?

1 Answer 147 Views
DropDownList Form
Jeff
Top achievements
Rank 1
Iron
Jeff asked on 16 Dec 2024, 07:14 PM

Hi, sorry if this is a basic question, but I cannot for the life of me figure out how to get this to work. I can have a DropDown list and a form separately, but when I try to put the DropDown into the form itself, I get a "Object of type 'Telerik.Blazor.Components.FormItem' does not have a property matching the name 'ChildContent'" error.

Here's a sample snippet of what I'm trying to do:



 <TelerikForm Model="@Input"
             Columns="3"
             ColumnSpacing="50px"
             OnValidSubmit="@HandleValidSubmit"
             OnInvalidSubmit="@HandleInvalidSubmit">
    <FormValidation>
        <DataAnnotationsValidator />
    </FormValidation>
    <FormItems>

<FormItem Field="@nameof(Model.Attribute)"></FormItem>
<FormItem Field="@nameof(Model.Attribute2)">
    <TelerikDropDownList Data="@myDdlData"
                         TextField="MyTextField"
                         ValueField="MyValueField"
                         @bind-Value="Model.Attribute3">
    </TelerikDropDownList>
</FormItem>
<FormItem Field="@nameof(Model.Attribute4)"></FormItem>

            </FormItems>
        </TelerikForm>
Sorry for the bad indentation, not sure how else to paste it properly.

1 Answer, 1 is accepted

Sort by
0
Accepted
Jeff
Top achievements
Rank 1
Iron
answered on 16 Dec 2024, 09:55 PM

Nevermind, sorry for the basic question. Seems like the solution is to use the <Template> tag before the DropDownList, like so:

 


<FormItem Field="@nameof(Model.Attribute)">
    <Template>
    <TelerikDropDownList Data="@DropDownData"
                         DefaultText="Select status"
                         ValueField="MyValueField"
                         @bind-Value="Input.Attribute">
    </TelerikDropDownList>
    </Template>
</FormItem>

Hristian Stefanov
Telerik team
commented on 16 Dec 2024, 10:25 PM

Hi Jeff,

I'm glad to hear that you have quickly resolved the matter on your own. Indeed, the <Template> tag is required so you can use the DropDownList inside the Form.

Thank you for sharing how things turned out publicly so other developers in the same situation can benefit from this.

Kind Regards,

Hristian

Tags
DropDownList Form
Asked by
Jeff
Top achievements
Rank 1
Iron
Answers by
Jeff
Top achievements
Rank 1
Iron
Share this question
or