Showing Selected Name In Drop Down While Updating

Hi Experts,

I’m able to show all the names in drop down while creating a record… how can show same dropdown value while updating…

Many Thanks,

Hoping to help this code for your problem

Do like that Model

public function selectStudentName()

{

$connection = yii::app()->db1;





$sql="Select Sid,StudentName from tbl_student";





$command=$connection->createCommand($sql); 


$students = $command->queryAll();





$studList = $this->getDropdownList($students,'Sid','StudentName');


		


return $studList;	

}

function getDropdownList($rows, $valueCol,$textCol)


{


	$newList = array();


	


	foreach($rows as $row)


	{


		$value = $row[$valueCol];


		$text = $row[$textCol];


					


		$newList[$value] = $text;


		//Syntax 


		//Newarayname[id col from Db]= text coloumn name from db


	}


		return 	$newList;





}

then do Like that Controller page

$students = $stud->selectStudentName();

$this->render(‘student’, array(‘rows’ => $rows));

then take rows value in student.php in view page area

thanks for your reply karthik…

I did it now in other way.

5n:)