DropDownListFor with Name getting cannot override component name when bound to a model expression error

1 Answer 219 Views
DropDownList TabStrip
Renu
Top achievements
Rank 1
Iron
Iron
Iron
Renu asked on 10 Oct 2024, 03:44 PM
I have a dropdownListFor in a View which is shared within the tabs in the Kendo Tabstrip. Due to cannot override component name when bound to a model expression error I have commented the Name configuration

My Dropdown:
@(Html.Kendo().DropDownListFor(m => m.Country)
       //.Name("city-" + (int)Model.CityID) -- Commented to resolve the error
       .DataSource(source =>
       {
           source.Read(read =>
           {
               read.Action("GetCities", "Home", new { countryID = (int)Model.CountryID})Type(HttpVerbs.Post);
           });
       })
       .OptionLabel("(Please Select))
       .HtmlAttributes(new
       {
           data_bind = "value: cityValue, events: { change: selectedCityChanged }"
       })
)

I have tab strip in which i don't have any issue with the first tab, but for other tabs, the control is not binded properly. Earlier i had the Name to prevent this bind issue.. Need help to fix this issue

I'm using Kendo 2024.3.806 version and ASP.NET Core MVC 8

First Tab:


Second Tab:

1 Answer, 1 is accepted

Sort by
0
Renu
Top achievements
Rank 1
Iron
Iron
Iron
answered on 12 Oct 2024, 11:49 AM

Fixed this issue by adding id to the HtmlAttribute

@(Html.Kendo().DropDownListFor(m => m.Country)
       .DataSource(source =>
       {
           source.Read(read =>
           {
               read.Action("GetCities", "Home", new { countryID = (int)Model.CountryID})Type(HttpVerbs.Post);
           });
       })
       .OptionLabel("(Please Select))
       .HtmlAttributes(new
       {

            id = "city-" + (int)Model.CityID,
           data_bind = "value: cityValue, events: { change: selectedCityChanged }"
       })
)

Alexander
Telerik team
commented on 14 Oct 2024, 07:53 AM

Sweet, thanks for keeping the community posted with you recent findings. This is highly appreciated.
Tags
DropDownList TabStrip
Asked by
Renu
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Renu
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or