InsertRow

Description

Inserts a row in a DataWindow or DataStore. If any columns have default values, the row is initialized with these values before it is displayed.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, DataStore object

Web

Client control, server component

Web ActiveX

DataWindow control, DataWindowChild object

Syntax

PowerBuilder and Web DataWindow server component

long dwcontrol.InsertRow ( long row ) 

Web DataWindow client control and Web ActiveX

number dwcontrol.InsertRow ( number row ) 

Argument

Description

dwcontrol

A reference to a DataWindow control, DataStore, or child DataWindow.

row

A value identifying the row before which you want to insert a row. To insert a row at the end, specify 0.

Returns

Returns the number of the row that was added if it succeeds and –1 if an error occurs.

If any argument’s value is null, in PowerBuilder and JavaScript the method returns null. If there is no DataWindow object assigned to the DataWindow control or DataStore, this method returns –1.

Usage

InsertRow simply inserts the row without changing the display or the current row. To scroll to the row and make it the current row, call ScrollToRow. To simply make it the current row, call SetRow.

A newly inserted row (with a status flag of New!) is not included in the modified count until data is entered in the row (its status flag becomes NewModified!).


Web DataWindow client control

Calling InsertRow causes the new status of the data to be sent back to the server where the data is retrieved again and the row is inserted. Then the page is reloaded.

If the DataWindow object has retrieval arguments, they must be specified in the HTMLGen.SelfLinkArgs property. For more information, see the HTMLGen.property, the Retrieve method, and the DataWindow Programmers Guide.

All methods that reload the page perform an AcceptText before sending data back to the server. If the method fails (returns –1), this means that pending data changes were not accepted and nothing was sent back to the server. In this situation the ItemError event occurs.

Examples

Example 1

This statement inserts an initialized row before row 7 in dw_Employee:

dw_Employee.InsertRow(7)

Example 2

This example inserts an initialized row after the last row in dw_employee, then scrolls to the row, which makes it current:

long ll_newrow

ll_newrow = dw_employee.InsertRow(0)

dw_employee.ScrollToRow(ll_newrow)

See also