Better way to find control in ASP.NET

后端 未结 9 1393
太阳男子
太阳男子 2020-11-22 03:17

I have a complex asp.net form,having even 50 to 60 fields in one form like there is Multiview, inside MultiView I have a GridView, and inside GridV

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 04:05

    I decided to just build controls dictionaries. Harder to maintain, might run faster than the recursive FindControl().

    protected void Page_Load(object sender, EventArgs e)
    {
      this.BuildControlDics();
    }
    
    private void BuildControlDics()
    {
      _Divs = new Dictionary();
      _Divs.Add(MyEnum.One, this.divOne);
      _Divs.Add(MyEnum.Two, this.divTwo);
      _Divs.Add(MyEnum.Three, this.divThree);
    
    }
    

    And before I get down-thumbs for not answering the OP's question...

    Q: Now, my question is that is there any other way/solution to find the nested control in ASP.NET? A: Yes, avoid the need to search for them in the first place. Why search for things you already know are there? Better to build a system allowing reference of known objects.

提交回复
热议问题