Data Binding Issues in MultiSelect Dropdown

I am trying to get MultiSelect Dropdown filled with Table Entries and then to populate some elements in already selected based on result from another table.
For Example: 

BusinessType Table:

1. Salons
2. Doctors
3. Dentists
4. Fitness Centers

CompanyBusinessType Table will contain CompanyID, BusinessTypeID from above Table (for example ABC Company has an ID = 1):
1 -> 1
means this company is a BusinessType of Salon.

I am trying to produce profile page of this company where if there have selected Salon already so it should be coming as selected in Dropdown when we will load this page.

VIEWMODEL:
    public class BusinessTypeViewModel
    {
        public int Id { get; set; }
        public string BusinessTypeName { get; set; }
    }

CONTROL:
               
                               DataSource="businessTypeViewModel" CssClass="text-custom2" AllowFiltering="true" AllowCustomValue="true" Value="@businessTypes" MaximumSelectionLength="@MaxSelectionBtype">
                   
                   
               

BASE CODE:
public List businessTypes = new List();


        public void OnTagging(TaggingEventArgs args)
        {
            System.Diagnostics.Debug.WriteLine($"OnTagging() -- businessTypes: {string.Join(',', businessTypes)}");
        }

protected override async Task OnInitializedAsync()
        {
            try
            {
                Globals.businessProfileViewModel = await GetBusinessProfileData();
                Globals.businessTypeViewModel = await GetBusinessTypes();
                var cbt = Globals.businessProfileViewModel.businessTypes.ToList();
                businessTypes.Add(cbt.Select(s => s.BusinessTypeNameEn).FirstOrDefault());

          }
           catch (Exception ex)
            {
                Console.WriteLine("Error in OnInit: " + ex.Message);
            }

If I change Id from int to string then it works but i cannot change value in MultiSelect, it always remain one assigned by OnInitializedAsync method 
businessTypes.Add(cbt.Select(s => s.BusinessTypeName).FirstOrDefault());
its "Salon"

Can you help me resolve this issue ?

Thank you

1 Reply 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team May 21, 2021 01:50 PM UTC

Hi Raheel, 


Greetings from Syncfusion support. 


We checked your query and attached code example. You used one way binding(Value) in the code, which does not update the value to the component immediately. To resolve the issue, change Value to @bind-Value and make sure TValue is of type int. Also ensure whether provided integer value is present in the data source or not. Please confirm whether or not this information helps you in resolving the reported issue. Refer the below code. 


<SfMultiSelect Placeholder="e.g. Australia" @bind-Value="@MultiVal" DataSource="@Country"> 
    <MultiSelectFieldSettings Value="Name"></MultiSelectFieldSettings> 
</SfMultiSelect> 
  

Please find the UG documentation link: 




If the above information does not help you in resolving the reported issue, kindly provide the video demonstration of the issue. 


Regards, 
Sevvandhi N 


Marked as answer
Loader.
Up arrow icon