我被派去维护一个网站。网站使用的是PRADO框架,我不得不做一些小改动。HTML和CSS的更改没有问题,但现在我必须将一些数据从页面传递到视图。我试过使用:
$this->HomeCalendar2->DataSource = $result['data'];
$this->HomeCalendar2->dataBind();但上面写着Component property 'Home.HomeCalendar2' is not defined.
在我的代码上面有以下代码:
$this->HomeCalendar->DataSource = $result;
$this->HomeCalendar->dataBind();它工作得很好,我看不出HomeCalendar的定义在哪里。任何帮助都将不胜感激。
附言:我以前从未和PRADO合作过。
发布于 2014-02-21 23:27:52
这个问题现在已经很老了,希望你已经解决了。
使用DataSource意味着在您的模板(.page或.tpl)中必须有一个TDataBoundControl组件,就像下面这样(例如,使用TRepeater )
<com:TRepeater ID="HomeCalendar">
<!--- [ properties like ItemTemplate here and it contents ] --->
</com:TRepeater>TDataBoundControl的子类用于需要循环结果的组件(以某种方式排序为for或foreach )。如果你只是需要将一个单一的结果传递给视图,你可以使用一个组件,比如TPanel/TActivePanel,TLiteral等等,或者简单地使用expression tag。
示例:
表达式标签:
Php:
<?php
$this->myvalue = 'Hello World!';模板:
<h1><%= $this->myvalue %></h1>或其他解决方案:
模板:
<com:TLiteral ID="MyLiteral" />PHP:
<?php
$this->MyLiteral->getControls()->add('<h1>Hello world !</h1>');https://stackoverflow.com/questions/16011360
复制相似问题