Tuesday, February 22, 2011

Primary key on custom query table

If you start with a TableControl from one database table, and later add some other joined table, the primary key ends being the combination of both table's primary keys, so the EditRowButton and such pass an incorrect value.
Solution: define a virtual primary key for the query being the primary key of the main table, and edit button's parameter to pass that value explicitely and not the control's PK.

Monday, February 21, 2011

More on using edit page as add

When implementing the changes noted before, you'll see that Formulas for controls only allow to enter data in "Initialize when ... Editing Record"
However, if you go to Custom Properties for the control, you can enter this key:
And it will take the formula for "Initialize when ... Adding Record"
It would be nice to find in the templates or code generator properties where or how ISD enable or disable this properties in the formula tab, but in the meantime this works.

Thursday, February 17, 2011

Modify code generator templates

In your ISD installation folder, navigate to


There you have all the files used to generate the code behind for pages. They're XSL files wich contain plain code (th resulting) and meta code. In order to use the changes proposed in the previous post, I modified


There I found the corresponding places and made the changes:

- In PageLoad(), around line 513, commented out: Panel.Visible = false;
- In CreateWhereClause, around line 1441, commented out exception throwing and added return null;
- In GetRecord, around line 2724 added some code, copied from line 2713, to return a new record if RecordUniqueID is null;

Now all the Edit pages create in ISD applications can be used as Add pages, without having to handcode.

Wednesday, February 16, 2011

Edit Record Page used as Add

In Section 1, TableRecordControl class, override the following methods:

public override WhereClause CreateWhereClause()
WhereClause wc;

wc = base.CreateWhereClause();
wc = null;
return (wc);

public override void LoadData()
System.Web.UI.WebControls.Panel Panel = (System.Web.UI.WebControls.Panel)MiscUtils.FindControlRecursively(this, "EntityRecordControlPanel");
if (Panel != null){
Panel.Visible = true;

public override EntityRecord GetRecord()
if (string.IsNullOrEmpty(RecordUniqueId))
return new EntityRecord();
return base.GetRecord();