Dynamic form with RadzenTemplateForm

Hello,

Is it possible to generate a form with radzen?
I have a database where i extract the structure from since i don't know how the table will look like.

so i have this c# class that will tell me the structure of the table:

public class TableDetailsDTO
{
    public string TableName { get; set; }
    public new List<ColumnDetail> ColumnsDetails { get; set; } = new List<ColumnDetail>();
}


public class ColumnDetail
{
    public string ColumnName { get; set; }
    public string DataType { get; set; }
    public List<ConstraintDetail> Constraints { get; set; } = new List<ConstraintDetail>();
    public string IsNullable { get; set; }
}

public class ConstraintDetail
{
    public string ConstraintType { get; set; }
    public string ReferenceTableName { get; set; }
    public string ReferenceColumnName { get; set; }
}

but is it possible to map this to the RadzenTemplateForm and how should i start with this?

Thanks in advance,

Hi @quintendc,

It is possible (most probably). You can check this thread for some ideas.

Hello,

I tried something like this:

<RadzenTemplateForm TItem=@(List<DbRecord>) Data=@DbRecords Submit=@((List<DbRecord> args) => { OnSubmit(args); })>

    @for (int i = 0; i < 2; i++)
    {
        <RadzenTextBox @bind-Value="@DbRecords.ElementAt(i).value"></RadzenTextBox>
    }


    <RadzenButton ButtonType="Radzen.ButtonType.Submit">Submit</RadzenButton>
</RadzenTemplateForm>
        List<DbRecord> DbRecords = new List<DbRecord>() {
            new DbRecord() { },
            new DbRecord() { },
            new DbRecord() { },
            new DbRecord() { },
            new DbRecord() { },
            new DbRecord() { },
        };


        private async Task OnSubmit(List<DbRecord> DbRecords)
        {

        }

but when i set a breakpoint on OnSubmit its not getting triggered?

thanks in advance,

There is probably an exception happening somewhere. Verify this is not the case. Also this isn't supported by Blazor binding:

@bind-Value="@DbRecords.ElementAt(i).value"

Check my response in the linked thread how to use the Value and Change events instead.