InsertRow method (DataWindows)
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.
Controls
DataWindow type |
Method applies to |
---|---|
PowerBuilder |
DataWindow control, DataWindowChild object, DataStore |
Web |
Client control, server component |
Web ActiveX |
DataWindow control, DataWindowChild object |
Syntax
[PowerBuilder and Web DataWindow server component]
1 |
long <span>dwcontrol</span><span>.InsertRow</span> ( long <span>row </span>) |
[Web DataWindow client control and Web ActiveX]
1 |
number <span>dwcontrol</span><span>.InsertRow</span> ( number <span>row </span>) |
Argument |
Description |
---|---|
dwcontrol |
A reference to a DataWindow control, |
row |
A value identifying the row before which |
Return Values
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
This statement inserts an initialized row before
row 7 in dw_Employee:
1 |
dw_Employee.<span>InsertRow</span>(7) |
This example inserts an initialized row after the
last row in dw_employee, then scrolls to the row, which
makes it current:
1 |
long ll_newrow |
1 |
ll_newrow = dw_employee.<span>InsertRow</span>(0) |
1 |
dw_employee.ScrollToRow(ll_newrow) |