Two way databinding in ASP.NET

后端 未结 5 1083
离开以前
离开以前 2021-01-18 14:29

Let say that we have an object

class Entity
{
    public string ID {get; set;}
    public string Name {get; set;}
}

I want to bind properti

5条回答
  •  佛祖请我去吃肉
    2021-01-18 15:09

    In the OnInit you are always making to null.. remove those code and keep in the page load..

    only need to bind in the very first time not in all the post back.

    Page_Load() {

    if(!Page.IsPostBack)
    {
         if (EntityObject== null) 
                EntityObject= new EntityObject(); 
    
            FormView.DataSource = new[] { EntityObject }; 
            FormView.DataBind(); 
     }
    

    }

提交回复
热议问题