Listbox Values

With version 18.1.0.36 why are the ListBox Values stored in what looks like JSON format - how do we just get the string value "3c38c84d-78eb-4b6e-bbe6-f5673af08791"



1 Reply

SD Saranya Dhayalan Syncfusion Team March 30, 2020 12:18 PM UTC

Hi Alex, 
 
Thank you for contacting Syncfusion support 
 
We have checked your reported issue, we are not able to reproduce it in our end. You can get the listbox value in string of array format(String[]). Please find the below code snippet: 
 
@using Syncfusion.Blazor.DropDowns 
 
@using Syncfusion.Blazor.Buttons 
 
<div class="col-lg-12 control-section"> 
    <div id="listbox-control"> 
        <SfListBox @ref="ListBoxObj" Value=@Value DataSource="@Data" TValue="string[]" TItem="DataValues"></SfListBox> 
        <SfButton Content="@Content" @onclick="OnClick"></SfButton> 
    </div> 
</div> 
 
 
 
<style> 
 
    #listbox-control { 
        width: 25%; 
        margin: auto; 
    } 
 
 
 
    @@media screen and (max-width: 590px) { 
        #listbox-control { 
            width: 100%; 
        } 
    } 
</style> 
 
 
 
@code{ 
    public SfListBox<string[], DataValues> ListBoxObj; 
    public string Content = "Get Value"; 
    public string[] Value = new string[] { "Hennessey Venom" }; 
    public List<DataValues> Data = new List<DataValues> 
{ 
        new DataValues{ text = "Hennessey Venom", id = "list-01" }, 
        new DataValues{ text = "Bugatti Chiron", id = "list-02" }, 
        new DataValues{ text = "Bugatti Veyron Super Sport", id = "list-03" }, 
        new DataValues{ text = "SSC Ultimate Aero", id = "list-04" }, 
        new DataValues{ text = "Koenigsegg CCR", id = "list-05" }, 
        new DataValues{ text = "McLaren F1", id = "list-06" }, 
        new DataValues{ text = "Aston Martin One- 77", id = "list-07" }, 
        new DataValues{ text = "Jaguar XJ220", id = "list-08" }, 
        new DataValues{ text = "McLaren P1", id = "list-09" }, 
        new DataValues{ text = "Ferrari LaFerrari", id = "list-10" } 
    }; 
    public class DataValues 
    { 
        public string text { get; set; } 
        public string id { get; set; } 
 
 
 
    } 
    public void OnClick(MouseEventArgs args) 
    { 
        string[] values = ListBoxObj.Value; 
         
    } 
} 
 
Please find the below screenshot: 
 
 
Please provide code snippet whether you have any customization done in the sample level and Kindly get back to us if you still getting the same issue or need further assistance on this.  
 
Regards, 
Saranya D 


Loader.
Up arrow icon