If you discover that a DataFormWebPart added programmatically is missing values in its built in XSL variables, like HttpVDir or PageUrl, verify that the ViewFlag attribute is set to something other than zero on your webpart. Took me some time to find out… Also, would be nice to know what this property stands for.