K13 DropDownComponent - How to bind with List

Kaur Navneet asked on May 10, 2023 12:40

I have the following code for a widget property: public const string LabID = "1;abc\r\n2;ab\r\n3;bv ..... etc"; [BindableProperty] [EditingComponent(DropDownComponent.IDENTIFIER, Order = 1, Label = "LabID")] [EditingComponentProperty(nameof(DropDownProperties.DataSource), LabID)] public string Language { get; set; } = "Alabama";

I have used a Dropdown component list like this "1;abc\r\n2;ab\r\n3;bv"; But this is too much longer a data list. I need a SelectListItem of data instead of this way of getting dropdwon list("1;abc\r\n2;ab\r\n3;bv";) How to bind another list like used in another model.

public IEnumerable< SelectListItem > StateList { get; set; } = new List< SelectListItem > { new SelectListItem{ Value="",Text="Choose A State..."}, new SelectListItem{ Value="AL",Text="Alabama"}, new SelectListItem { Value = "CA", Text = "Canada" }, new SelectListItem { Value = "US", Text = "USA" }, new SelectListItem { Value = "AK", Text = "Alaska" } };

Recent Answers


Juraj Ondrus answered on May 10, 2023 14:27

I believe that this is the documentation you are looking for.

0 votesVote for this answer Mark as a Correct answer

Kaur Navneet answered on May 10, 2023 14:44 (last edited on May 11, 2023 06:40)

Hi Juraj Ondrus ,

public const string LabID = "1;abc\r\n2;ab\r\n3;bv ..... etc"; [BindableProperty] [EditingComponent(DropDownComponent.IDENTIFIER, Order = 1, Label = "LabID")] [EditingComponentProperty(nameof(DropDownProperties.DataSource), LabID)]

The above is the property being set for widget properties, so what I want to achieve here is that I have a widget and I am adding some property fields for the widget. One of the field is dropdown, now the data for that dropdown is being set as shown above.

But I want to set its data using a List, instead of a string?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.