Several online searches give me the impression that very few people like to write about data binding when no object collections are involved. There are resources on using FormView etc. with data binding, but these are as scarce as rainbows in a coal mine.
Could some of you please suggest some nice, thorough articles on data binding for editing object details in a custom web form, i.e. not using any auto-generated edit forms etc.
I will probably be seen as winging too much and doing to little, but I have deadlines for a prototype and quickly need something between a mock-up of what the app will do, and a functional first iteration. Later on I will write of what I learn as an article, hopefully making others' quests for info on this subject easier.
If you are really after binding a single record and you don't want to go the simple route of just using 2 methods that set / get values from the controls, you can use a FormView (full control) or a DetailsView (table layout, yet you can have custom html). There are samples in msdn: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.formview.aspx and http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.detailsview.aspx.
Its no secret when its on msdn ;)
As you mentioned you can use asp.net dynamic data. And if you are not tied to regular asp.net, on asp.net mvc you get the object into the controller methods populated from the data in the request, and you have a clear way to "bind" what you want to render on the view.
I used FormView and DetailsView for some time in some projects. It works but it didn't buy you that much. Nowadays I actually don't like it at all, mainly because I don't like the way it leads you to structure your application.
I usually use the "Brute Force" method defined in this article. It only takes a few minutes to make a LoadToForm and LoadFromForm method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With