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
-
Open Editors/Products.aspx in the WebForm Designer
-
Select the DataGrid control and open its Columns
property editor
-
Switch to the Format tab and select the Columns/ProductID/Items
item in TreeView
-
Choose the Right item in the Horizontal Alignment
drop-down list
-
Set the Right alignment for all other numeric fields
-
Click OK
b. Change the alignment of the numeric text fields
-
Switch from Design to HTML
view
-
Add style="text-align: right" to all the numeric asp:TextBox
controls
Figure 5.1
c. Display text values for foreign keys
-
Modify
the supplier column ItemTemplate by replacing
<asp:Label
Text='<%# DataBinder.Eval(Container.DataItem,
"SupplierID") %>' runat="server"
/>
with
<asp:Label
Text="<%#
GetSupplierName(Container.DataItem) %>"
runat="server" />
-
Open the code-behind class
-
Add the GetSupplierName
method as shown below
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
-
Perform
the same steps for the CategoryID column

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.