0
votes

well i have made an object for datawindow in which i made columns name as name age gender etc. this table does not exist in database and during the design of datawindow object i have selected external style as dw object. so no what actually i want to do is to insert the data using script in these column. for insertinf row i simple used Datawindowcontrol.insertrow(row) in the itemchanged event of datawindow. but it just adds the row i want data to insert there... thanks in advance for yor comments...

3

3 Answers

1
votes

Alternative implementation using ".object" notation (faster than GetItem/SetItem in recent PB versions):

long newRow
newRow = this.RowCount( ) + 1

this.object.name[newRow]   = dw_entry.object.name[1]
this.object.gender[newRow] = dw_entry.object.gender[1]
0
votes

The insertrow method only inserts a new row in a datawindow control. You would have to populate it with the data if that is your intention. Simple code example is this:

long ll_row
ll_row = dw_save.insertrow(0)
dw_save.setitem(ll_row, "name", dw_entry.getitemstring(1,"name"))
dw_save.setitem(ll_row, "gender", dw_entry.getitemstring(1, "gender))

The above assumes you have a data entry datawindow with only a single line and a second datawindow which will save the data to the database.

You should change your design somewhat since the itemchanged event is triggered each time the user goes from field to field in the datawindow control.

0
votes

well this statement works perfectly here....

this.insertrow( 1)
this.setitem(1,1,23)
this.setitem(1,2,today())
this.setitem(1,3,13.5)
this.insertrow( 2)
this.setitem(2,1,25)
this.setitem(2,2,today())
this.setitem(2,3,14.5)