Foreach loop is not displaying Divs/Child in ListView Template

I am building questionnaire component and able to show Question text in ListView using Template. However when I try to display Options for that particular questions, it doesn't work.


div id="questionnaireTarget">
                        <SfDialog Width="1080px" Height="700px" Target="#questionnaireTarget" ShowCloseIcon="true" @bind-Visible="@DialogVisible">
                            <DialogTemplates>
                                <Header>Questionnaire</Header>
                                <Content>
                                    <SfListView DataSource="@Questionnaire">
                                        <ListViewFieldSettings Id="QuestionnaireId" Text="QuestionText" TValue="QuestionnaireX" />
                                        <ListViewTemplates TValue="QuestionnaireX">
                                            <Template>
                                                <span style="display: block; word-wrap:break-word; white-space: normal">
                                                    @context.QuestionText
                                                </span>
                                                @{
                                                    foreach (var option in context.Options)
                                                    {
                                                        <div>
                                                            @option.OptionText
                                                        </div>
                                                    }
                                                }
                                            </Template>
                                        </ListViewTemplates>
                                    </SfListView>
                                </Content>
                            </DialogTemplates>
                            <DialogButtons>
                                <DialogButton Content="Save" IsPrimary="true" OnClick="OnQuestionnaireSaveClick"></DialogButton>
                                <DialogButton Content="Cancel" IsPrimary="true" OnClick="OnQuestionnaireCancelClick"></DialogButton>
                            </DialogButtons>
                        </SfDialog>
                    </div>


public class QuestionnaireX : BaseModel
    {
        public long QuestionnaireId { get; set; }
        public long QuestionId { get; set; }
        public string QuestionText { get; set; }
        public List<QuestionOptionModel> Options { get; set; }
    }

1 Reply

IL Indhumathy Loganathan Syncfusion Team January 17, 2022 02:54 PM UTC

Hi Faizan, 
 
Greetings from Syncfusion support. 
 
We have prepared a Blazor ListView sample with shared code snippet but we are unable to replicate the reported issue at our end.  
 
 
Kindly check the above sample and modify the ListView items like your code to replicate the issue from our end along with your package version. These details would help us to assist you promptly. 
 
Regards, 
Indhumathy L 


Loader.
Up arrow icon