|
Step 1: Using the Application Wizard in Iron Speed Designer, create a sample application using
the Orders table in the Northwind database.
Step 2: Drag a button control from the Iron Speed Designer tool box and place it next to the Export
button in the Show Orders Table page. Set the Button text to "myButton" in the Display tab of the Page Properties
dialog for the button. Then, select "Send custom command" in the Bindings tab of the Page Properties dialog and
enter the command name "myCustomCommand".
Step 3: Drag a text box control from the Iron Speed Designer tool box and place it on the page.
Select an appropriate database table and database field in the Bindings tab of the Page Properties dialog
box of the text box control. This binds the control to the database so that it can fetch and update data
from the database.
Step 4: Override the OnApplicationEvent method in the TableControl class. The GetSelectedRecord method
is used to get the database record for the row that is currently selected.
For .NET Framework 1.1, add the code in the OrdersTableControl class of ShowOrdersTablePage.aspx.cs, located in:
|
...\<Application Folder>\Orders\ShowOrdersTablePage.aspx.cs
|
For .NET Framework 2.0, add the code in the OrdersTableControl class of ShowOrdersTablePage.Controls.cs,
located in:
|
...\<Application Folder>\App_Code\Orders\ShowOrdersTablePage.Controls.cs
|
C#:
public override void OnApplicationEvent(BaseClasses.ApplicationEventArgs args)
{
if(args.CustomEventName=="myCustomCommand")
{
OrdersRecord mySelectedRecord = this.GetSelectedRecord(false);
if(mySelectedRecord != null)
{
this.Textbox.Text = mySelectedRecord.CustomerID.ToString() + " " +
mySelectedRecord.EmployeeID.ToString();
}
else
{
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "my_Key", "Please select a record");
}
}
base.OnApplicationEvent (args);
}
|
Visual Basic .NET:
Public Overrides Sub OnApplicationEvent(ByVal args As BaseClasses.ApplicationEventArgs)
If args.CustomEventName = "myCustomCommand" Then
Dim mySelectedRecord As OrdersRecord = Me.GetSelectedRecord(False)
If (Not mySelectedRecord Is Nothing) Then
Me.Textbox.Text = mySelectedRecord.CustomerID.ToString + " " +
mySelectedRecord.EmployeeID.ToString
Else
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "my_Key", "Please select a record")
End If
End If
mybase.OnApplicationEvent(args)
End Sub
|
Note: "Textbox" is the name of the text box control in the HTML layout page file.
Step 5: Build and run your application.
Note: You can also use the "Handle Selected Record" code customization example in the "Selected Row
Handling" section of the Code Customization Wizard in Iron Speed Designer.
|