Step 5: Extending generated code

After you have created the application, you may want to customize the output code to suite your specific requirements. Let's consider a few examples so you could see for yourself how easy it is to modify the generated code.

We will perform the following tasks:

a. Change the alignment of the numeric DataGrid fields.
b. Change the alignment of the numeric text fields.
c. Display text values for foreign keys.

a. Change the alignment of the numeric DataGrid fields
b. Change the alignment of the numeric text fields
Extending the generated WebForm code

Figure 5.1

c. Display text values for foreign keys

C#:
protected string GetSupplierName(object productsRow)
{
    using(RapTier.Tutorial.Db.Northwind db = new RapTier.Tutorial.Db.Northwind())
    {
        SuppliersRow supplier = db.SuppliersCollection.GetByPrimaryKey(
               Convert.ToInt32(DataBinder.Eval(productsRow, "SupplierID")));
        return supplier.CompanyName;
    }
}

VB.NET:
Protected Function GetSupplierName(productsRow As Object) As String
    Dim db As RapTier.Tutorial.Db.Northwind = _
                  New RapTier.Tutorial.Db.Northwind()
    Try
        Dim supplier As SuppliersRow = _
             db.SuppliersCollection.GetByPrimaryKey( _
             Convert.ToInt32(DataBinder.Eval(productsRow, "SupplierID")))
        Return supplier.CompanyName
    Finally
        db.Dispose()
    End Try
End Function




Figure 5.2

Conclusion

This tutorial has been written to give RapTier users an insight into how the generated applications can be customized to fit your development requirements.

If you have questions or comments please address those to our support team at support@SharpPower.com. We welcome your feedback.

For more information about the generated classes, methods and properties see the User Guide section in the documentation.