What is a DataWindow?

Since I started Blogging about the .NET DataWindow. I have had some developers ask the following questions:

  • What is so great about a DataWindow?
  • Why do you care if you can use one in your .NET application?
  • Why not just use a DataGrid?

I thought I would try and answer some of these questions for those that have never used Powerbuilder.

First you must realize there are two different objects that both get called a DataWindow. A PowerBuilder developer knows which you are talking about by the context it's used in. They are

  • DataWindow Object - Class which contains the Presentation and SQL to retrieve Data and display it to the user.
  • DataWindow Control - A Control you place on your window that takes a DataWindow Object as one of it's parameters. This object presents the DataWindow Object to the user on your form.
    • Inheritable
    • Sample Methods
      • Retrieve
      • Update
    • Sample Events
      • RowFocusChanged
      • ItemChanged

In the DataWindow editor you define a DataSource, the problem is that DataSource is part of the Datawindow Object. Sybase has to change the .NET Datawindow to take an external DataSource, like a DataSet or Business Object that implements IListSource. I may write something that hooks a DataSet to a DataWindow if I get time. Perhaps Sybase will fly me down to meet with the.NET DataWindow Architects and give them some suggestions. Hint Hint

Back to how it works. Once you have your Data Source defined you move to the presentation side of the DataWindow. Here is the good thing about having the data and presentation together in one object. There is no binding issues. You get a column for each column in the result set. So you paint your Datawindow and please realize this is not just a grid. This can be a graph, labels, grid, tabular or you can make it look just like a for with buttons, group boxes, textboxes and labels.

Once you have a completed DataWindow. You drop a DataWindow Control on your form set the DataObject Property to the name of your DataWindow Object. Then just tell the DataWindow Control what Transaction you are using and call the retrieve method.

So that is a really simple example of how it works. In my next Blog entry I'll tell you why I think they are so good.