Getting a keyField column from the CGridView or dataProvider

II just want it to list

a bunch of fields from the database table and if the edit button is selected go to a view for update.

The trouble Is I can not figure out thus far how to access the keyField which I need in my edit button event:Here is an excerp of working code:

I know the $dataProvider defines an array with

I can generate the data grid and it fills in the columns in the grid with good data, however

[size="7"]What can I do to extract the id value [/size]

I mean the Id columbn value displayed in the grid

Note the dataprovider used:

$dataProvider = new CSqlDataProvider($sql,array(

          'keyField'=>'Id',.

So far I have tried:

obtaining the values I need via:

$dataProvider->params->keyField ?

$dataProvider->params->keyField->id ?

I also noted that the CSqlDataProvider

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

    'id'=&gt;'gridx', <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/ohmy.gif' class='bbc_emoticon' alt=':o' /> 


    'dataProvider'=&gt;&#036;dataProvider,


    'columns'=&gt; array(


     array(


    'class'=&gt;'CButtonColumn',

‘template’=>’{update}’,

    'updateButtonUrl'=&gt;'Yii::app()-&gt;createUrl(&quot;GoUpdateRec&quot;,

array("id"=>$dataProvider->params->keyField

)

)’,) ,

‘Id’,‘TitleId’,‘UserId’

)

)

)

I already tried print_r on the dataprovider

Then tried $dataProvider->

There has to be a way to access the data for the grid columns either directly via the grid object or

the dataprovider object. It stands to reason.

Perhaps using the properties or methods available in those objects or parent class objects??

PLEASE PLEASE PLEASE LAUGH AT ME ALL YOU LIKE BUT HELP ME. I REALLY NEED THE HELP ON THIS

I have a perfectly good Grid screen

Perhaps using getkeys or some such method???

Please HELP HELP HELP. I am trying here will repost later hopefully more intelligible by then!

The data property from CDataProvider is your friend. See the class reference for more information: CDataProvider

Never used CSqlDataProvider but all of them has a getData() and for the button’s url you just use $data->Id not $dataProvider as it is $data what is passed to CButtonColum… Please, refer to CButtonColumn line 63 for further reference…

Has to be $data["Id"], though. Good explanation here.

/Tommy