Click here to Skip to main content
13,145,405 members (82,507 online)
Rate this:
Please Sign up or sign in to vote.
This is a general Q is looping through controles faster then directly accessing it in WEB if yes then how if no then how can some one plz Explain me this
Thanks in advance
Posted 4-Jul-11 22:42pm
Updated 4-Jul-11 22:43pm
CPallini 5-Jul-11 5:04am
Well 'direct' in 'direct access' is an hint, isn't it?
Steven.Pinto2000 5-Jul-11 5:11am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

No, looping to lists is never faster than accessing data directly. This is because it will always perform extra steps and checks.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Direct access is always faster than looping as JV99999 pointed out the reason.

But in certain circumstances where you got to add/show random controls based on some criteria, then accessing it thru loops is better way to set or retrieve its value or so. Not necessary for each stage you got to access it via loop only, you can add TAG to each control and access particular control based on its index.

Conclusion : For stable controls, direct access is preferred and for dynamically adding a # of specific controls (Like textboxes, checkboxes, etc) yuo may access it via loops but always loops are not required and nor the preferred way.

Now it depends on your requirements and what do you want to do.

Hope this helps !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 5 Jul 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100