How can I use architecture-disabled DataBound controls in ASP.NET?

When I develop ASP.NET applications, I often create forms that allow users to create, retrieve, or update records in the database. Many times it is necessary to be able to add children to an element that I am creating, like adding a category to a product or some sort of order / order relationship. I usually use some kind of DropDownList to show a list of possible child records and then a DataGrid to show which children are already part of the parent. Currently the only way I know this in ASP.NET requires that I first save the parent record to the DB so that I can assign the PK / FK relationship so that I can DataBind DataGrids that store the child records.

What I would like to know is that somehow I could implement the form so that I can add or remove records from these DataGrids, but not actually commit the changes until the user clicks the Save button to create or update all required records at once. I'm starting to migrate from using SubSonic to LINQ if that works better for DataBinding. This looks pretty complicated with HTTP statelessness.

Any thoughts are appreciated,

Mike

+2


source to share


1 answer


You can use a cached DataSet for this . They are largely intended to be used as an in-memory representation of table-based relational data. In fact, I really don't recommend this approach for a variety of reasons, but you can cache your DataSet on the server, allow the user to interact with it (add, edit, delete, etc.) via postbacks, and then only save the changes to the real the base database at the end.



I think the best way to do this is to make all changes to the underlying database when the user enters them into a transaction and then only commits the transaction at the end.

+1


source







All Articles