id not found in CButtonColumn

Hi… :rolleyes: i have problem, about view button url an CButtonColumn - CGridView.

i use CSQLDataprovider to get data from sql.

this my gridview code:

$this->widget('zii.widgets.grid.CGridView', array(






            'firstname::First Name' ,        





            'viewButtonLabel'=>'Show Data',


my problem in this line:


because, id at account.view not get value from field database: $data->customer_id

the result of url is:


i want url to be:


This works well if using CActiveDataProvider but not with CSqlDataProvider

But do you see the value of customer_id in the first column ?

In the code you have


generaly here is something like


and search() is a method that returns an CActiveDataProvider… so in your case it would return CSqlDataProvider…

yes, is see customer_id in first column.

this is $model code:

$sql ="select * From customer order by firstname,lastname";

            $count = Yii::app()->db->createCommand('select COUNT(*) from customer')->queryScalar();

            $model= new CSqlDataProvider($sql,array(










does not work

ok done,

i replace this line:


so, my questions is, why is there a difference when render data to CGridView, between CSqlDataProvider and CActiveDataProvider. whether this was made ​​like this ?

Great you found that out… I completely forgot it… as the doc say (http://www.yiiframew…SqlDataProvider):

while CActiveDataProvider as the doc say (http://www.yiiframew…iveDataProvider):

thank you, i can see in this note: