copy child records

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
snookie
User
Posts: 34

copy child records

Post by snookie »

Hi,
is it possible to copy a record, including all it's child records from another table, if any?
If yes, how to do it?

Thanks, snookie.


motfs
User
Posts: 258

Post by motfs »

If copy, there is key in the URL, e.g. <Table>add.asp?showdetail=&<key>=<value>.

  1. Get the key value (ew_Get("<key>")) in the Page_Load server event and save it in Session Variable.
  2. In the Row_Inserted server event, you can retrieve the detail records with the key value stored and execute (ew_Execute()) your insert statement.

snookie
User
Posts: 34

Post by snookie »

hi,
the ew_Get("ID") did not work for me in the Row_Inserted event.... it was always empty when copying or cloning a record.
I don't know why.

Instead I used the following code to define whether it was an 'add' or 'copy' event, and this worked for me: (VB)

	Public Overrides Sub Row_Inserted(rsold As OrderedDictionary, rsnew As OrderedDictionary)	
		.....			
		if rsold is Nothing then
			tmp_action = "add"               
		else     
			tmp_action = "copy"
		end if

lfernandes
User
Posts: 77

Post by lfernandes »

To resolve this issue, follow these steps

  1. At the server events ListOptions_Load include:
    var opt = ListOptions.Add("copy");
    opt.Header = "";
    opt.OnLeft = true; // Link on left

  2. At the server events ListOptions_Rendered include:
    Body = "<a href='xxxadd.cshtml?showdetail=detailtable&ID=" + key.CurrentValue + "' title='Copy'>";
    Body = Body + "<span class='icon-copy ewIcon' data-caption='Copy'></span></a>";
    ListOptions["copy"].Body = Body ;


Post Reply