dkarzon dkarzon - 1 year ago 136
C# Question

ASP.NET Dynamic form generation and submition

I need to create a form where for each day in the month the user will enter in several different values (Im thinking a grid sort of thing, values along the top, day of the month along the side) using ASP.NET forms with C# backend...

So what would be the best way to generate this form? I dont want to hardcode that many controls as it would make the submition a little annoying but i also would need to be able to give it values entered in previous days and have it display them in the textboxes.

How would i go about creating this form and also how would i get the values from the textboxes in the backend?

Answer Source

Here is an example application that creates a dynamic form and submits it back to the database. It's written in VB.Net but im sure it's easily converted to C#.

Basically the way it works is adding the controls to the form dynamically then accessing the values that are posted to the server with the Request.Form collection.