Syntax for selected data in a named column

Description

A DataWindow data expression uses the Selected property to access values in a named column or computed field for the currently selected rows. Selected data is always in the primary buffer.

Syntax

dwcontrol.Object.columnname {.Primary } {.datasource }.Selected

Parameter

Description

dwcontrol

The name of the DataWindow control or child DataWindow in which you want to get or set data.

columnname

The name of a column or computed field in the DataWindow object in dwcontrol. If the column or computed field does not exist at runtime, an execution error occurs.

datasource

(optional)

The source of the data. Values are:

  • Current -- (Default) The current values in the DataWindow control.

  • Original -- The values that were initially retrieved from the database. For a computed field, you must specify Original (because computed fields cannot be changed and do not have current values).


Return value

The datatype of the expression is Any. The expression returns an array of values with the datatype of columnname.

Usage

When you specify selected values, the expression always returns an array and you must assign the result to an array, even if you know there is only one row selected.

For selected rows, the primary buffer is the only applicable buffer. For consistency, you can include Primary in this syntax but it is not necessary.

Examples

Because the primary buffer is the only applicable buffer for selected data and current data is the default, these expressions are all equivalent. They access values in the emp_name column for selected rows:

dw_1.Object.emp_name.Selected
dw_1.Object.emp_name.Primary.Selected
dw_1.Object.emp_name.Current.Selected
dw_1.Object.emp_name.Primary.Current.Selected

These expressions both access original values for selected rows:

dw_1.Object.emp_name.Original.Selected
dw_1.Object.emp_name.Primary.Original.Selected

This example sets the emp_name value in the first selected row to an empty string. The rest of the selected rows are set to a default value, which can be an empty string:

string ls_empty[]
ls_empty[1] = ""
dw_1.Object.emp_lname.Selected = ls_empty

This statement gets the original emp_name values in selected rows and assigns them to an array of strings:

string ls_namearray[]
ls_namearray = dw_1.Object.emp_name.Original.Selected