在Symfony2中嵌入表单集合时出错(Error when embed a collection of Forms in Symfony2)

我正在尝试在symfony2应用程序中嵌入一组表单。 我需要简单的实体: ShopAddress商店有多个地址。 我按照Symfony2文档,但我收到错误:

属性“地址”和方法之一“getAddress()”,“address()”,“isAddress()”,“hasAddress()”,“__ get()”都不存在,并且在类“AppBundle”中具有公共访问权限实体\地址”。 500内部服务器错误 - NoSuchPropertyException

在我看来,它试图访问我的Address Entityaddress preoperty。

这是我的Shop Entity

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use AppBundle\Entity\Address;
use UserBundle\Entity\Seller;

/**
 * Shop
 *
 * @ORM\Table(name="app_shop")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\ShopRepository")
 */
class Shop
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     * @ORM\Column(name="shopName", type="string", length=255)
     */
    private $shopName;

    /**
     * @var string
     * @ORM\Column(name="description", type="text", nullable=true)
     */
    private $description;

    /**
     * @var string
     * @ORM\Column(name="ownerName", type="string", length=255)
     */
    private $ownerName;

    /**
     * @ORM\ManyToOne(targetEntity="UserBundle\Entity\Seller", cascade={"refresh"}, fetch="EAGER")
     * @ORM\JoinColumn(nullable=false, onDelete="NO ACTION")
     * @Assert\Valid()
     */
    private $owner;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\Address", mappedBy="shop")
     * @Assert\Valid()
     */
    private $address;

    /**
     * @ORM\Column(type="string", nullable=true)
     * @Assert\Length(
     *      min = 9,
     *      max = 10,
     *      minMessage = "Le numéro siret doit contenir 10 chiffres",
     *      maxMessage = "Le numéro siret doit contenir 10 chiffres"
     * )
     */
    private $siret;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Image")
     * @ORM\JoinColumn(nullable=true)
     */
    private $image;


    public function __construct() 
    {
        $this->address = new ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set shopName
     *
     * @param string $shopName
     * @return Shop
     */
    public function setShopName($shopName)
    {
        $this->shopName = $shopName;

        return $this;
    }

    /**
     * Get shopName
     *
     * @return string 
     */
    public function getShopName()
    {
        return $this->shopName;
    }

    /**
     * Set shopName
     *
     * @param string $description
     * @return Shop
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     * @return string 
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set ownerName
     *
     * @param string $ownerName
     * @return Shop
     */
    public function setOwnerName($ownerName)
    {
        $this->ownerName = $ownerName;
        return $this;
    }

    /**
     * Get ownerName
     *
     * @return string 
     */
    public function getOwnerName()
    {
        return $this->ownerName;
    }

    /**
     * Set siret
     *
     * @param string $siret
     * @return Shop
     */
    public function setSiret($siret)
    {
        $this->siret = $siret;
        return $this;
    }

    /**
     * Get siret
     *
     * @return string
     */
    public function getSiret()
    {
        return $this->siret;
    }


    /**
     * Set address
     *
     * @param ArrayCollection $address
     *
     * @return Address
     */
    public function setAddress(ArrayCollection $address)
    {
        $this->address = $address;
        return $this;
    }

    /**
     * Get address
     *
     * @return \AppBundle\Entity\Address
     */
    public function getAddress()
    {
        return $this->address;
    }

    /**
     * Set owner
     *
     * @param \UserBundle\Entity\Seller $owner
     *
     * @return Owner
     */
    public function setOwner(Seller $owner = null)
    {
        $this->owner = $owner;
        return $this;
    }

    /**
     * Get owner
     *
     * @return \UserBundle\Entity\Sellers
     */
    public function getOwner()
    {
        return $this->owner;
    }


    /**
     *
     * @param Image $image
     * @return \AppBundle\Entity\Shop
     */
    public function setImage(Image $image)
    {
        $this->image = $image;
        return $this;
    }

    /**
     *
     */
    public function getImage()
    {
        return $this->image;
    }

}

这是我的Address Entity

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;


/**
 * Adress
 *
 * @ORM\Table(name="app_address")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\AddressRepository")
 */
class Address
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="street", type="string", length=255)
     * @Assert\Length(  min = 5 , 
     *                  max = 200,
     *                  minMessage = "L'adresse doit faire au minimum {{ limit }} caractères.",
     *                  maxMessage = "L'adresse doit faire au maximum {{ limit }} caractères.")
     * 
     */
    private $street;

    /**
     * @ORM\Column(type="string", length=5)
     * @Assert\Regex(
     *     pattern="/^\d{4,5}$/",
     *     match=true,
     *     message="Le format n'est pas correct"
     * )
     */
    private $postalCode;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $city;

    /**
     * @var string
     *
     * @ORM\Column(name="country", type="string", length=255 , nullable=true)
     * @Assert\Length(  min = 3 ,
     *                  max = 50,
     *                  minMessage = "Le pays doit faire au minimum {{ limit }} caractères.",
     *                  maxMessage = "L'adresse doit faire au maximum {{ limit }} caractères.")
     *
     */
    private $country;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Shop", inversedBy="address")
     * @ORM\JoinColumn(name="shop_id", referencedColumnName="id")
     */
    private $shop;

    /**
     * Get id
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set street
     *
     * @param string $street
     *
     * @return Address
     */
    public function setStreet($street)
    {
        $this->street = $street;

        return $this;
    }

    /**
     * Get street
     *
     * @return string
     */
    public function getStreet()
    {
        return $this->street;
    }

    /**
     * Set postalCode
     * @return Address
     */
    public function setPostalCode($postalCode)
    {
        $this->postalCode = $postalCode;
        return $this;
    }

    /**
     * Get postalCode
     */
    public function getPostalCode()
    {
        return $this->postalCode;
    }

    /**
     *
     * @param string
     * @return \AppBundle\Entity\Address
     */
    public function setCity($city = null)
    {
        $this->city = $city;
        return $this;
    }

    /**
     *
     */
    public function getCity()
    {
        return $this->city;
    }

    /**
     *
     * @param string
     * @return \AppBundle\Entity\Address
     */
    public function setCountry($country = null)
    {
        $this->country = $country;
        return $this;
    }

    /**
     *
     */
    public function getCountry()
    {
        return $this->country;
    }

    /**
     *
     * @param Shop
     * @return \AppBundle\Entity\Address
     */
    public function setShop($shop = null)
    {
        $this->shop = $shop;
        return $this;
    }

    /**
     *
     */
    public function getShop()
    {
        return $this->shop;
    }

    public function __toString() {
        return $this->street." ".$this->postalCode." ".$this->city;
    }
}

我创建了两个formType来管理我的实体:

ShopType.php

<?php

namespace AppBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;

use AppBundle\Form\AddressType;
use AppBundle\Entity\Shop;
use AppBundle\Entity\Address;

class ShopType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('shopName', TextType::class, array('label' => 'Nom du magasin *', 'required' => true, 'error_bubbling' => true))
            ->add('ownerName', TextType::class, array('label' => 'Nom du gérant *', 'required' => true, 'error_bubbling' => true))

            ->add('address', CollectionType::class, array(  'entry_type' => AddressType::class,
                                                            'allow_add' => true,
                                                            'label' => 'Adresse *', 
                                                            'required' => true
            ));
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
                'data_class' => Shop::class,
        ));
    }
}

AddressType.php

<?php

namespace AppBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\OptionsResolver\OptionsResolver;

use AppBundle\Entity\Address;

class AddressType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('address', TextType::class, array('label' => 'Adresse*', 'required' => true))
            ->add('CodePostal', TextType::class, array('label' => 'Code postal*', 'required' => true, 'error_bubbling' => true))
            ->add('Ville', TextType::class, array('label' => 'Ville', 'required' => false, 'error_bubbling' => true))
            ->add('Pays', 'choice', array(
                    'choices'   => array(
                            'FR'   => 'France',
                            'SU'   => 'Suisse',
                            'BE'    => 'Belgique'
                    )
            ))
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
                'data_class' => Address::class,
        ));
    }

    public function getName()
    {
        return 'addresse';
    }
}

在我的控制器中,我正在实现我的表格如下:

$shop = $shopRepo->findOneByOwner($user);
if ($shop == null){
    $shop = new Shop();
}
$form = $this->createForm(ShopType::class , $shop);

I'm trying to embed a collection of forms in a symfony2 application. I have to simple entities : Shop and Address whith a Shop which has multiple address. I follow the Symfony2 documentation but I get the error :

Neither the property "address" nor one of the methods "getAddress()", "address()", "isAddress()", "hasAddress()", "__get()" exist and have public access in class "AppBundle\Entity\Address". 500 Internal Server Error - NoSuchPropertyException

It seems to me that it is trying to access the address preoperty of my Address Entity.

Here is my Shop Entity

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
use AppBundle\Entity\Address;
use UserBundle\Entity\Seller;

/**
 * Shop
 *
 * @ORM\Table(name="app_shop")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\ShopRepository")
 */
class Shop
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     * @ORM\Column(name="shopName", type="string", length=255)
     */
    private $shopName;

    /**
     * @var string
     * @ORM\Column(name="description", type="text", nullable=true)
     */
    private $description;

    /**
     * @var string
     * @ORM\Column(name="ownerName", type="string", length=255)
     */
    private $ownerName;

    /**
     * @ORM\ManyToOne(targetEntity="UserBundle\Entity\Seller", cascade={"refresh"}, fetch="EAGER")
     * @ORM\JoinColumn(nullable=false, onDelete="NO ACTION")
     * @Assert\Valid()
     */
    private $owner;

    /**
     * @ORM\OneToMany(targetEntity="AppBundle\Entity\Address", mappedBy="shop")
     * @Assert\Valid()
     */
    private $address;

    /**
     * @ORM\Column(type="string", nullable=true)
     * @Assert\Length(
     *      min = 9,
     *      max = 10,
     *      minMessage = "Le numéro siret doit contenir 10 chiffres",
     *      maxMessage = "Le numéro siret doit contenir 10 chiffres"
     * )
     */
    private $siret;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Image")
     * @ORM\JoinColumn(nullable=true)
     */
    private $image;


    public function __construct() 
    {
        $this->address = new ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set shopName
     *
     * @param string $shopName
     * @return Shop
     */
    public function setShopName($shopName)
    {
        $this->shopName = $shopName;

        return $this;
    }

    /**
     * Get shopName
     *
     * @return string 
     */
    public function getShopName()
    {
        return $this->shopName;
    }

    /**
     * Set shopName
     *
     * @param string $description
     * @return Shop
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     * @return string 
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set ownerName
     *
     * @param string $ownerName
     * @return Shop
     */
    public function setOwnerName($ownerName)
    {
        $this->ownerName = $ownerName;
        return $this;
    }

    /**
     * Get ownerName
     *
     * @return string 
     */
    public function getOwnerName()
    {
        return $this->ownerName;
    }

    /**
     * Set siret
     *
     * @param string $siret
     * @return Shop
     */
    public function setSiret($siret)
    {
        $this->siret = $siret;
        return $this;
    }

    /**
     * Get siret
     *
     * @return string
     */
    public function getSiret()
    {
        return $this->siret;
    }


    /**
     * Set address
     *
     * @param ArrayCollection $address
     *
     * @return Address
     */
    public function setAddress(ArrayCollection $address)
    {
        $this->address = $address;
        return $this;
    }

    /**
     * Get address
     *
     * @return \AppBundle\Entity\Address
     */
    public function getAddress()
    {
        return $this->address;
    }

    /**
     * Set owner
     *
     * @param \UserBundle\Entity\Seller $owner
     *
     * @return Owner
     */
    public function setOwner(Seller $owner = null)
    {
        $this->owner = $owner;
        return $this;
    }

    /**
     * Get owner
     *
     * @return \UserBundle\Entity\Sellers
     */
    public function getOwner()
    {
        return $this->owner;
    }


    /**
     *
     * @param Image $image
     * @return \AppBundle\Entity\Shop
     */
    public function setImage(Image $image)
    {
        $this->image = $image;
        return $this;
    }

    /**
     *
     */
    public function getImage()
    {
        return $this->image;
    }

}

Here is my Address Entity

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;


/**
 * Adress
 *
 * @ORM\Table(name="app_address")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\AddressRepository")
 */
class Address
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="street", type="string", length=255)
     * @Assert\Length(  min = 5 , 
     *                  max = 200,
     *                  minMessage = "L'adresse doit faire au minimum {{ limit }} caractères.",
     *                  maxMessage = "L'adresse doit faire au maximum {{ limit }} caractères.")
     * 
     */
    private $street;

    /**
     * @ORM\Column(type="string", length=5)
     * @Assert\Regex(
     *     pattern="/^\d{4,5}$/",
     *     match=true,
     *     message="Le format n'est pas correct"
     * )
     */
    private $postalCode;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $city;

    /**
     * @var string
     *
     * @ORM\Column(name="country", type="string", length=255 , nullable=true)
     * @Assert\Length(  min = 3 ,
     *                  max = 50,
     *                  minMessage = "Le pays doit faire au minimum {{ limit }} caractères.",
     *                  maxMessage = "L'adresse doit faire au maximum {{ limit }} caractères.")
     *
     */
    private $country;

    /**
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Shop", inversedBy="address")
     * @ORM\JoinColumn(name="shop_id", referencedColumnName="id")
     */
    private $shop;

    /**
     * Get id
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set street
     *
     * @param string $street
     *
     * @return Address
     */
    public function setStreet($street)
    {
        $this->street = $street;

        return $this;
    }

    /**
     * Get street
     *
     * @return string
     */
    public function getStreet()
    {
        return $this->street;
    }

    /**
     * Set postalCode
     * @return Address
     */
    public function setPostalCode($postalCode)
    {
        $this->postalCode = $postalCode;
        return $this;
    }

    /**
     * Get postalCode
     */
    public function getPostalCode()
    {
        return $this->postalCode;
    }

    /**
     *
     * @param string
     * @return \AppBundle\Entity\Address
     */
    public function setCity($city = null)
    {
        $this->city = $city;
        return $this;
    }

    /**
     *
     */
    public function getCity()
    {
        return $this->city;
    }

    /**
     *
     * @param string
     * @return \AppBundle\Entity\Address
     */
    public function setCountry($country = null)
    {
        $this->country = $country;
        return $this;
    }

    /**
     *
     */
    public function getCountry()
    {
        return $this->country;
    }

    /**
     *
     * @param Shop
     * @return \AppBundle\Entity\Address
     */
    public function setShop($shop = null)
    {
        $this->shop = $shop;
        return $this;
    }

    /**
     *
     */
    public function getShop()
    {
        return $this->shop;
    }

    public function __toString() {
        return $this->street." ".$this->postalCode." ".$this->city;
    }
}

I created two formType in order to manage my entities :

ShopType.php

<?php

namespace AppBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;

use AppBundle\Form\AddressType;
use AppBundle\Entity\Shop;
use AppBundle\Entity\Address;

class ShopType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('shopName', TextType::class, array('label' => 'Nom du magasin *', 'required' => true, 'error_bubbling' => true))
            ->add('ownerName', TextType::class, array('label' => 'Nom du gérant *', 'required' => true, 'error_bubbling' => true))

            ->add('address', CollectionType::class, array(  'entry_type' => AddressType::class,
                                                            'allow_add' => true,
                                                            'label' => 'Adresse *', 
                                                            'required' => true
            ));
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
                'data_class' => Shop::class,
        ));
    }
}

AddressType.php

<?php

namespace AppBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\OptionsResolver\OptionsResolver;

use AppBundle\Entity\Address;

class AddressType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('address', TextType::class, array('label' => 'Adresse*', 'required' => true))
            ->add('CodePostal', TextType::class, array('label' => 'Code postal*', 'required' => true, 'error_bubbling' => true))
            ->add('Ville', TextType::class, array('label' => 'Ville', 'required' => false, 'error_bubbling' => true))
            ->add('Pays', 'choice', array(
                    'choices'   => array(
                            'FR'   => 'France',
                            'SU'   => 'Suisse',
                            'BE'    => 'Belgique'
                    )
            ))
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
                'data_class' => Address::class,
        ));
    }

    public function getName()
    {
        return 'addresse';
    }
}

In my controller, I'm instanciating my form as following :

$shop = $shopRepo->findOneByOwner($user);
if ($shop == null){
    $shop = new Shop();
}
$form = $this->createForm(ShopType::class , $shop);

原文:https://stackoverflow.com/questions/41248211
2022-12-11 14:12

满意答案

你混淆了一切。
了解每个部分在这里做什么,并了解为什么这不起作用。

持有GridView的Parent.aspx页面以及她内部的UpdatePanel需要回发到同一页面并从同一页面返回工作。

具有jQuery并加载Parent.aspx的另一个页面是获取结果,将其呈现到不同的页面,并且Parent.aspx包含的javascript从不运行。 现在, Parent.aspx的完整代码位于其他页面中,您尝试再次对Parent.aspx进行ajax调用,并获得结果?

网格视图是一种“开箱即用”的控件,需要一些标准的方法来正确工作。 UpdatePanel的设计可以容纳GridView,它们可以一起工作,因为它们就是这样设计的。

如果你添加jQuery加载,那么你需要自定义所有逻辑,制作自定义网格视图,自定义调用等。

如果你混淆它们,它们很简单就行不通了。


You have mix up everything.
Understand what each part do here and you understand why this can not work.

Parent.aspx page that hold the GridView and also have inside her the UpdatePanel need to make post back to the same page and get return from the same page to work.

The other page that have the jQuery and load the Parent.aspx is get the results, rendered it to a different page and the javascript that Parent.aspx contains never run. Now the full code of the Parent.aspx is inside some other page and you try to make an ajax call to the Parent.aspx again, and get results where ?

The grid view is an "out of the box" control that need some standard way to correctly work. The UpdatePanel have been design that can hold the GridView and they can work together because they have been design that way.

If you add jQuery load, then you need to make all that logic custom, to make your custom grid view, your custom calls etc.

If you mix them up, they simple not work.

相关问答

更多

Jquery分页滚动如facebook状态(Jquery paging scroll such as facebook status)

$('#yourcontainerId').bind('scroll', function(){ if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) { alert('this will alert only when it reaches the end'); } }); $('#yourcontainerId').bind('scroll', function(){ ...

GridView的自动分页不起作用(GridView's Automatic paging doesn't work)

当您回发时,您必须将数据重新绑定到gridview。 您可能还需要设置页码,如: GridView1.CurrentPageIndex = e.NewPageIndex; When you post back, you'll have to rebind the data to the gridview. You may also need to set the page number like: GridView1.CurrentPageIndex = e.NewPageIndex;

通过Jquery调用页面时,GridView分页不起作用(GridView Paging Not Working When Page Is Called via Jquery)

你混淆了一切。 了解每个部分在这里做什么,并了解为什么这不起作用。 持有GridView的Parent.aspx页面以及她内部的UpdatePanel需要回发到同一页面并从同一页面返回工作。 具有jQuery并加载Parent.aspx的另一个页面是获取结果,将其呈现到不同的页面,并且Parent.aspx包含的javascript从不运行。 现在, Parent.aspx的完整代码位于其他页面中,您尝试再次对Parent.aspx进行ajax调用,并获得结果? 网格视图是一种“开箱即用”的控件,...

GridView分页无法按预期工作(GridView paging not working as expected)

这就是我做的...... Protected Sub gvExistingICByUser_PageIndexChanging(sender As Object, e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvExistingICByUser.PageIndexChanging Dim grid As GridView = DirectCast(sender, GridView) ...

Gridview分页不起作用(Gridview paging not working)

你的绑定顺序不正确。它应该像... protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.SelectedIndex = -1; BindGrid(); // Call bind here } Your binding order is not correct.. I...

gridview分页(gridview paging)

使用GridView的内置函数并一次加载整个数据。 当您的记录数量如此之小时,在数据库(带有RowNumber)中实现分页是不值得的,特别是因为您提到您正在寻找快速解决方案。 在GridView中启用分页时,性能就足够了。 Use the builtin functions of the GridView and load the whole data at one go. It wouldn't be worth the effort to implement paging in databas...

分页GridView(Paging GridView)

好的,很容易 处理代码后面的PageIndexChanging事件, C# void GridView1_PageIndexChanging(Object sender, GridViewPageEventArgs e) { //For example //Cancel the paging operation if the user attempts to navigate //to another page while the GridView control is i...

GridView分页不起作用?(GridView Paging is not working?)

我认为你错过了gridview中的OnPageIndexChanging事件。 尝试将此添加到您的gridview OnPageIndexChanging="UserListGridViewIndexChanging"和后端代码中 protected void UserListGridViewIndexChanging(object sender, GridViewPageEventArgs e) { UserListGridView.PageIndex = e.NewPa...

Gridview分页不起作用?(Gridview pagination not working?)

作为一个简单的解决方案,更改PageIndexChanging方法。 只需在代码中调用get_table()方法即可。 查看更新的代码。 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; get_table(); } As a simple solutio...

Wordpress WP分页(插件)分页链接不起作用......?(Wordpress WP Paging (plugin) pagination links not working…?)

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?> 确保您的通话中有上述行 - 正如您引用$ paged,但不要在您的问题中显示! <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?> Make sure you have the above line in your call - a...

相关文章

更多

Symfony2网站开发

http://blog.csdn.net/liubei5/article/details/132902 ...

Hibernate 异常之:associate a collection with two ...

Hibernate exception - Illegal attempt to associate ...

英语谚语精选(English Proverb Collection)

Lying is the first step to the gallows. 说谎是上断头台的第 ...

用好Collection 对solrj入库进行优化

今天一个朋友找我说他进行入库测试: 1个collection 2个shard,30多个字段,一个小时才 ...

Solr参数(Analysis Collection Common CoreAdmin)

一.Analysis 1.analysis.query:Holds the query to be a ...

Securing Solr on Tomcat access using a user account

Open [Tomcat install dir]\tomcat-users.xmlfor editi ...

ServletOutputStream cannot be resolved to a type

在使用jsp生成web图片时遇到这个问题,这是源代码中的一条语句,源代码可以执行,可是一将源码放入ec ...

Spark - A Fault-Tolerant Abstraction for In-Memory Cluster Computing

http://spark-project.org/ 项目首页 http://shark.cs.berk ...

Spring Data: a new perspective of data operations

Spring Data: a new perspective of data operations ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本