This is a migrated thread and some comments may be shown as answers.
Setting Field and Title in loop
1 Answer 37 Views
This is a migrated thread and some comments may be shown as answers.
Randy Hompesch
Top achievements
Rank 1
Randy Hompesch asked on 10 Nov 2019, 10:10 AM

Hi,

Here's what I want to do

@for (int i = 0; i < 14; i++)
{
    <GridColumn Field="@CellDate + (i + 1).ToString()" Title="@SelectedStartDate.AddDays(i).ToShortDateString()" />
}

But I can't seem to get it to compile. It throws and error:

 error RZ9986: Component attributes do not support complex content (mixed C# and markup).

So I get that it doesn't support complex content. I can easily put one line per field, but I don't know the title until runtime. How to set the title as desired?

Is there a way to throw this in a loop at all?

Thanks … Ed

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 11 Nov 2019, 08:19 AM

Hello Ed,

In Blazor, you must use @foreach loops. For some reason, they are the only loop that works, the "standard" @for loop does not.

You can find an example of doing this in the following page: https://feedback.telerik.com/blazor/1418456-bind-to-datatable. If it matches your needs, you can also Vote for it and Follow it.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
Tags
Grid
Asked by
Randy Hompesch
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or