Q:

magento edit not working in admin form

I try to add new Form Every filed save properly in database 
<?php

class MPS_Gallery_Adminhtml_GalleryController extends Mage_Adminhtml_Controller_action
{

    protected function _initAction()
    {
        $this->loadLayout()
            ->_setActiveMenu('gallery/items')
            ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
        return $this;
    }    

    public function indexAction() {
        $this->_initAction();        
        $this->_addContent($this->getLayout()->createBlock('gallery/adminhtml_gallery'));
        $this->renderLayout();
    }

    public function editAction()
    {
        $galleryId     = $this->getRequest()->getParam('id');
        $galleryModel  = Mage::getModel('gallery/gallery')->load($galleryId);

        if ($galleryModel->getId() || $galleryId == 0) {

            Mage::register('gallery_data', $galleryModel);

            $this->loadLayout();
            $this->_setActiveMenu('gallery/items');

            $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
            $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));

            $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);

            $this->_addContent($this->getLayout()->createBlock('gallery/adminhtml_gallery_edit'))
                 ->_addLeft($this->getLayout()->createBlock('gallery/adminhtml_gallery_edit_tabs'));

            $this->renderLayout();
        } else {
            Mage::getSingleton('adminhtml/session')->addError(Mage::helper('gallery')->__('Item does not exist'));
            $this->_redirect('*/*/');
        }
    }

    public function newAction()
    {
        $this->_forward('edit');
    }

    public function saveAction()
    {
        if ( $this->getRequest()->getPost()) {
            if (isset($_FILES['imageurl']['name']) && $_FILES['imageurl']['name'] != '') {
            try {
                $postData = $this->getRequest()->getPost();
                $uploader = new Varien_File_Uploader('imageurl');
                $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png')); // Your Format Here
                $uploader->setAllowRenameFiles(true);
                $uploader->setFilesDispersion(false);
                $path = Mage::getBaseDir('media').DS.'Gallery'.DS;                
                $img = $path. $_FILES['imageurl']['name'];
                $filename = $uploader->getNewFileName($img);
                $uploader->save($path, $filename);
                $galleryModel = Mage::getModel('gallery/gallery');                
                $galleryModel->setId($this->getRequest()->getParam('id'))
                    ->setTitle($postData['title'])
                    ->setDescription($postData['description'])
                    ->setStatus($postData['status'])
                    ->setImageurl('/Gallery/'.$filename)
                    ->save();
                //var_dump($uploader);exit();

                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved'));
                Mage::getSingleton('adminhtml/session')->setgalleryData(false);

                $this->_redirect('*/*/');
                return;
            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                Mage::getSingleton('adminhtml/session')->setgalleryData($this->getRequest()->getPost());
                $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
                return;
            }
        }
    }
        $this->_redirect('*/*/');
    }

    public function deleteAction()
    {
        if( $this->getRequest()->getParam('id') > 0 ) {
            try {
                $galleryModel = Mage::getModel('gallery/gallery');
                $galleryModel = Mage::getModel('gallery/gallery')->load($this->getRequest()->getParam('id'));
                $image = $galleryModel->getImageurl();
                $path = Mage::getBaseDir('media').DS.'Gallery'.DS; 
                unlink($path.$image);
                $galleryModel->delete();
                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
                $this->_redirect('*/*/');
            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
            }
        }
        $this->_redirect('*/*/');
    }
}

if i try to edit already available value it not update database

A:

Try this,
change only your saveAction()
public function saveAction(){
         if ($data = $this->getRequest()->getPost()){
            $model = Mage::getModel('gallery/gallery');
            $id = $this->getRequest()->getParam('id');
            foreach ($data as $key => $value){
                if (is_array($value)){
                    $data[$key] = implode(',',$this->getRequest()->getParam($key));
                }
            }
            if($id){
                $model->load($id);
            }
            //Code to Save Gallery Image
            if(isset($_FILES['imageurl']['name']) && (file_exists($_FILES['imageurl']['tmp_name']))){
                try{
                    $uploader = new Varien_File_Uploader('imageurl');
                    $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png')); // or pdf or anything
                    $uploader->setAllowRenameFiles(false);
                    // setAllowRenameFiles(true) -> move your file in a folder the magento way
                    $uploader->setFilesDispersion(false);
                    $path = Mage::getBaseDir('media').'/Gallery/';
                    $imgName = explode('.',$_FILES['imageurl']['name']);
                    $imgName[0] = $imgName[0].'-'.'gallery-img'.'-'.date('Y-m-d H-i-s');
                    $imgName = implode('.',$imgName);
                    $imgName = preg_replace('/\s+/', '-', $imgName);
                    $uploader->save($path, $imgName);
                    $data['imageurl'] = 'Gallery/'.$imgName;
                }catch(Exception $e){

                }
            }
            else{       
                if(isset($data['imageurl']) && $data['imageurl']['delete'] == 1){
                    // delete image file
                    $image = explode(',',$data['imageurl']);
                    $img = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA).'/'.$image[1];
                    if(file_exists($img)){
                        unlink($img);
                    }
                    // set db blank entry
                    $data['imageurl'] = ''; 
                }else{
                    unset($data['imageurl']);
                }
            }
            $model->setData($data);
            Mage::getSingleton('adminhtml/session')->setFormData($data);
            try{
                if ($id){
                    $model->setId($id);
                }
                $model->save();
                if (!$model->getId()){
                    Mage::throwException('Error saving slide details');
                }
                Mage::getSingleton('adminhtml/session')->addSuccess('Details was successfully saved.');
                Mage::getSingleton('adminhtml/session')->setFormData(false);

                // The following line decides if it is a "save" or "save and continue"
                if ($this->getRequest()->getParam('back')) {
                    $this->_redirect('*/*/edit', array('id' => $model->getId()));
                }else{
                    $this->_redirect('*/*/');
                }
            }catch(Exception $e){
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                if ($model && $model->getId()) {
                    $this->_redirect('*/*/edit', array('id' => $model->getId()));
                } else {
                    $this->_redirect('*/*/');
                } 
            }
            return;
        }
        Mage::getSingleton('adminhtml/session')->addError('No data found to save');
        $this->_redirect('*/*/'); 

    }

