Thursday, May 28, 2015

Binding Entries Back From GridView to Dataset

The Manage 2000 DAC architecture relies on strongly typed datasets to manage the movement of business object data between UniData and ASP.NET webcontrols.  The table adapters generated for the datasets handle the binding of data from dataset to the webcontrols very nicely.  There are not, however, any generated methods for Update, Change or Delete operations.

It is possible without an awful lot of code to handle the gridview row events and utilizing the strongly typed dataset methods move the data back into the dataset from the UI.

Here is the SoWebShipments page converted to use GridView controls in place of UltraWebGrid controls:


To move the data back into the dataset we just need to handle the RowUpdating event to move the data and then handle the RowUpdated event to tell the grid the we handled the problem with the missing Update Method on our table adapter. In order to support deleting rows we do the same exercise in the RowDeleted and RowDeleting events handlers.



Monday, April 6, 2015

"And the beat goes on. And the beat goes on."

Yes Ma, I'm still here tinkerin with M2k.

One of the major tasks we are undertaking in developing the next release is to go through all the web pages that have grids on them and do a proper house cleaning.  Its like when you buy new appliances for the kitchen, you're gonna want scrub a little bit behind where the fridge and stove have been settled for the last decade or two. And you are probably going to find things that you wish you hadn't.  But a thorough cleaning every 10 or 20 years brings you closer to God.

So I have been becoming one with the Microsoft GridView component. To begin with I thought it was simple and a bit clumsy with the whole Templated Column approach for links and whatnot.  And there are times when the object model gets annoying as you try to get after some behavior programmatically.  But I have found it to be remarkably pliable.

One of the astonishing things I found was the ability to databind in the aspx file to a group of children of the current row.  Manage 2000 has always used strongly typed datasets in order to get nice design time support in Visual Studio.  But this also means that strongly typed datarows know how to get their children.

The unfortunate part is some rather scary looking casting in order to access the strongly typed datasets properties and methods.  And also the ever annoying IsxxxNull checks that are a must for optional fields.

But the amazing part is adding a templated column in the aspx and having a child set of sub-values or sub-sub-values unfurl before the user:


So the Planned Components are being bound directly in the aspx file from databinding references:

DataSource="<%# DirectCast(DirectCast(Container.DataItem, System.Data.DataRowView).Row, ROISystems.Components.dstItemOrderListing.MFGORDERRES_Order_DetailRow).GetMFGORDERRES_Order_ComponentsRows %>"