Skip to content

Commit d6097bc

Browse files
author
syncsiva
committed
Passed obj instead of using hard-coded type in CreateComponent method.
1 parent a43c704 commit d6097bc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Pages/Index.razor

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<h3>Dynamic form</h3>
77
<EditForm Model="@employeeDetails" OnValidSubmit="@Submit">
88
<DataAnnotationsValidator />
9-
@CreateComponent()
9+
@CreateComponent(@employeeDetails)
1010
<ValidationSummary></ValidationSummary>
1111
<div class="form-group">
1212
<button type="submit" class="btn btn-primary">Save</button>
@@ -23,9 +23,10 @@
2323
Countries countries = new Countries();
2424
Cities cities = new Cities();
2525

26-
public RenderFragment CreateComponent() => builder =>
26+
public RenderFragment CreateComponent(object modelobj) => builder =>
2727
{
28-
var proList = typeof(EmployeeDetails).GetProperties();
28+
29+
var proList = modelobj.GetType().GetProperties();
2930
foreach (var prp in proList)
3031
{
3132
Type T = prp.GetType();

0 commit comments

Comments
 (0)