FormView.FindControl() returns null until DataBind()

后端 未结 5 2036
轻奢々
轻奢々 2020-12-19 23:24

Why method FindControl() returns null on FormView until call DataBind().

After that it returns everything correct

5条回答
  •  长情又很酷
    2020-12-19 23:58

    It is very odd. Did not work for me just calling DataBind(). I had to create a new List, add an item, set as datasource, then databin.

    List dummyList = new List();
    dummyList.Add(new Item());
    formview.DataSource = dummyList;
    formview.DataBind();
    

提交回复
热议问题