Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for Guidance on Data Binding in ASP.NET Detail Forms

Tags:

asp.net

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.

like image 562
ProfK Avatar asked Nov 06 '22 20:11

ProfK


2 Answers

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.

like image 144
eglasius Avatar answered Nov 14 '22 22:11

eglasius


I usually use the "Brute Force" method defined in this article. It only takes a few minutes to make a LoadToForm and LoadFromForm method.

like image 24
Greg Avatar answered Nov 14 '22 21:11

Greg