❔ Using razor pages to generate a list and send to code file
So I have a table called GenericEvents, and I have various activities that use this generic event to do scheduling on a calendar.
The generic events are popualted using model binding when an event is create, and users populate date/time/ other info.
With the standard CRUD pages that scaffolding pumps out, I can setup one genericEvent using the provided form, but what I'd like to do is be able to generate a List<genericEvent> so that one activity can be bound to multiple generic events (recurring).
is there a way to model bind a List<T> of POCO objects that's driven by input from the view?
For example, I'd like a button that would add a new generic event to the page model, and a UI element to set the values for that GenericEvent, then have the submit button send that List<GenericEvent> to the code behind file to be added to the db.
Any general pattern I could follow to accomplish this easily without looping in react or something?
I'd like to be able to create multiple generic events (like in this image) at runtime, is there a way to dynamically create page elements like these or is this locked to server-side functionality?
25 Replies
Orightcha, Let me read this ( fair headsup, I am learning blazor myself so this might get a bit bumpy)
I know this is doable, because you're requesting nothing outlandish I just don't know from top of my head how this is done.
It takes a wee bit of googling for me, if you want to wait for another helper , that's ok.
What is your timeframe for solving this?
haha I was hoping to get it figured out today
this isnt the only place im looking
If you place it in some place and use another account to give the ABSOLUTE wrong answer, people will jump on it to correct that answer, that one still works.
and yeah I did a lot of googling, they all seem to be intent on doing this in reverse order, generating an empty list and letting the ui populate that, rendering out using a for loop
but IDK how many generic events they will need so they need to add them at create-time
yeah this seems like it should be dead simple with blazor but alas im stuck
brb with some coffee and I will write some things down. that are crucial for your fix.
can you hover over Generic events and tell me what error it gives?
oh its becasue I changed it to a LIST<GenericEvent> in the model and this is an individual Generic event
its just in the middle of implementation lol
it would be fixed if I added a [0]
I did find this reddit thread
https://www.reddit.com/r/Blazor/comments/jpn17o/comment/gbg2i9m/
reddit
r/Blazor - Comment by u/Petermae on ”How to create a component dyna...
2 votes and 7 comments so far on Reddit
going to try to see if this will do what I want
it does seem to be based on a for loop so I'm a little worried its not going to behave clientside the way I think it will
What is your current hosting model?
IIS express
LOL we aren't deployed to prod yet. Still in dev
probably going to host it in azure tho
yeah I was wondering about the type of blazor, Server or WASM
I have to dissapoint you at this point I am Mostly familiar with one-way-binding.
dang
is this getting close to your case?
https://blazorforums.net/topic/61/how-to-do-data-binding-on-dynamic-form-in-blazor
How to do data binding on dynamic form In Blazor ?
Hi All, I have requirement to create the tabular template entry form, I am generating the form dynamically using look. But whenever i m giving inp...
I'm not sure, I'll read through it. Got work starting soon
Yeah well, I'm working lists here too.
I will be on standby for this, because I need to know this ruckus as well.
@MAR'🥚EntireTeamIsBabies! I may have found it
Stack Overflow
MVC Razor create list of objects to submit
I am an experienced .NET C# Software Developer, however only a few months ago i started worked with MVC Razor (MVC 5).
I have a small situation that i couldn't find any answer to on the net(after...
OH! MVC!
Wasn't even thinking about that
yeah IDK how mixing that into my razor page will wo0rk but it might be a solution
I was just reading 2 way binding like so:
<input @bind="dataInput" />
The two-way binding in Blazor is achieved using the @bind keyword, which is typically used as an attribute.
But yeah Cheers on you topman.I mean its still not a razor solution so it might not map over 1:1
but your case is quite domainspecific.
I hope it works, I will remain on standby in case it goes sideways.
No response has been made since Last correspondence, I have been on Standby since 14:59, We can regard this case as closed.
Thank you for trusting me to look over this case.
Happy trails.
I mean I didn't a tually get a solution and would appreciate if other people more familiar with razor pages could still take a look
Of course you didn't get a response I went to work lol
Do you wish to Reopen the Case?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.