Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
Hi 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
Updated 4-Jul-11 22:43pm
v2
Comments
CPallini 5-Jul-11 5:04am    
Well 'direct' in 'direct access' is an hint, isn't it?
Steven.Pinto2000 5-Jul-11 5:11am    
yes

No, looping to lists is never faster than accessing data directly. This is because it will always perform extra steps and checks.
 
Share this answer
 
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 !
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900