diff options
author | xue <> | 2006-02-04 05:05:03 +0000 |
---|---|---|
committer | xue <> | 2006-02-04 05:05:03 +0000 |
commit | e7622f08814c6c7a1166addf9bc23c5780bd74b0 (patch) | |
tree | 67f9648fb6c9b62688a0acebb33d8788c506c13c /framework/Web/UI/WebControls/TRepeater.php | |
parent | f97358b8da7a2cbb1bf6438298286f7290616381 (diff) |
Fixed a bug about performing databind with an empty dataset.
Diffstat (limited to 'framework/Web/UI/WebControls/TRepeater.php')
-rw-r--r-- | framework/Web/UI/WebControls/TRepeater.php | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php index fc997323..65b3106e 100644 --- a/framework/Web/UI/WebControls/TRepeater.php +++ b/framework/Web/UI/WebControls/TRepeater.php @@ -372,21 +372,24 @@ class TRepeater extends TDataBoundControl implements INamingContainer protected function performDataBinding($data)
{
$this->reset();
- $itemIndex=0;
$items=$this->getItems();
- $hasSeparator=$this->_separatorTemplate!==null;
- foreach($data as $dataItem)
+ $itemIndex=0;
+ if($data instanceof Traversable)
{
- if($itemIndex===0 && $this->_headerTemplate!==null)
- $this->_header=$this->createItemInternal(-1,'Header',true,null);
- if($hasSeparator && $itemIndex>0)
- $this->createItemInternal($itemIndex-1,'Separator',true,null);
- $itemType=$itemIndex%2==0?'Item':'AlternatingItem';
- $items->add($this->createItemInternal($itemIndex,$itemType,true,$dataItem));
- $itemIndex++;
+ $hasSeparator=$this->_separatorTemplate!==null;
+ foreach($data as $dataItem)
+ {
+ if($itemIndex===0 && $this->_headerTemplate!==null)
+ $this->_header=$this->createItemInternal(-1,'Header',true,null);
+ if($hasSeparator && $itemIndex>0)
+ $this->createItemInternal($itemIndex-1,'Separator',true,null);
+ $itemType=$itemIndex%2==0?'Item':'AlternatingItem';
+ $items->add($this->createItemInternal($itemIndex,$itemType,true,$dataItem));
+ $itemIndex++;
+ }
+ if($itemIndex>0 && $this->_footerTemplate!==null)
+ $this->_footer=$this->createItemInternal(-1,'Footer',true,null);
}
- if($itemIndex>0 && $this->_footerTemplate!==null)
- $this->_footer=$this->createItemInternal(-1,'Footer',true,null);
$this->setViewState('ItemCount',$itemIndex,0);
}
|