Exception

Please help me to understand why this doesn't work (does compile, any errors are just from pulling this snippet out):

@using Syncfusion.Blazor.DropDowns; 

<table>
    <tr>
        <td>
            Project:
        </td>
        <td>
            <SfComboBox AllowCustom="false" TValue="ProjectType?" TItem="ProjectType" @bind-Value="@selectedProjectType" DataSource="@ProjectTypes">
                <ComboBoxFieldSettings Text="Text"></ComboBoxFieldSettings>
            </SfComboBox>
        </td>
    </tr>
</table>

@code {
    protected ProjectType? selectedProjectType;
    protected class ProjectType
    {
        public int Id { get; set; } = 0;
        public string Text { get; set; } = "";
        public int Points { get; set; } = 0;

        public override string ToString()
        {
            return Text;
        }
    }
    protected List<ProjectType> ProjectTypes = new List<ProjectType>()
    {
        new ProjectType() { Id = 1, Text  = "Large Medical Hospital", Points = 10},
        new ProjectType() { Id = 2, Text  = "Small Medical Hospital/Clinic", Points = 10},
        new ProjectType() { Id = 3, Text  = "Commercial Office New", Points = 10},
        new ProjectType() { Id = 4, Text  = "Commercial Office Remodel", Points = 10},
        new ProjectType() { Id = 4, Text  = "School", Points = 10},
    };


    protected override void OnInitialized()
    {


        base.OnInitialized();
    }
}


Gives an exception when a selection is made:



3 Replies 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team December 3, 2020 04:04 PM UTC

Hi Jonah, 

Thanks for contacting Syncfusion support. 

We suggest you to change the TValue as ProjectType as like below code snippet to get rid of the reported issue. Please find the code snippet and sample below for reference. 

<SfComboBox AllowCustom="false" TValue="ProjectType" TItem="ProjectType" @bind-Value="@selectedProjectType" DataSource="@ProjectTypes"> 
     <ComboBoxFieldSettings Text="Text"></ComboBoxFieldSettings> 
</SfComboBox> 
 
@code { 
    protected ProjectType selectedProjectType; 
    protected class ProjectType 
    { 
        public int Id { get; set; } = 0; 
        public string Text { get; set; } = ""; 
        public int Points { get; set; } = 0; 
 
        public override string ToString() 
        { 
            return Text; 
        } 
    } 
  

Kindly check with the above sample to get rid of the reported issue. Please get back us if you need further assistance. 

Regards, 
Ponmani M 


Marked as answer

JC Jonah Coleman December 3, 2020 05:21 PM UTC

Appears to work fine in newest release- unfortunately I'm stuck in .48 due to some other issues.  Thanks!


PO Prince Oliver Syncfusion Team December 4, 2020 05:30 AM UTC

Hi Jonah, 

Thank you for your confirmation. We are glad that the issue is resolved in the latest release. Please let us know if you need any further assistance on this. 

Regards, 
Prince 


Loader.
Up arrow icon