Assigning filename for export to pdf - in customtemplate view page

Hi experts, I created a custom view page and want to export it to PDF by changing the name with the following code in the Page_Exporting() event:

if ($this->isExport("pdf")) {
$doc->FileName = "payroll_" . $this->ID->CurrentValue;
}

But the code I tried doesn't work at all. Am I missing something?

  1. Which version are you using?
  2. If your "custom view page" means Custom View, do not use it anymore, convert it to a database view and try again.
  3. You did not post your complete server event, make sure you return true if want to use default export and skip Row_Export event.